Multiple fixes (#29)

* Multiple fixes

- add goreleaser to the build / release process
- add kubectl plugin for job graphs visualization
- add installation scripts
- update dependencies

* Update the release & CRD content.

* Next set of improvements.

  Code Quality

  - Label constants: Added LabelWorkflowName, LabelGroupName, LabelJobName, LabelJobID in controllers/definitions.go
  - Removed commented debug code: Cleaned up dead code from multiple files
  - Removed unused dependencyTree field: Cleaned connPackage struct
  - Fixed snake_case variables: Changed to camelCase (runGroup, groupDep, runJob, jobDep, k8sJob)

  Kubernetes Best Practices

  - Finalizers: Implemented handleDeletion() and deleteChildJobs() for proper cleanup
  - Status enum validation: Added +kubebuilder:validation:Enum=pending;running;succeeded;failed;aborted
  - ImagePullPolicy default: Created getImagePullPolicy() helper that defaults to IfNotPresent
  - Resource limits support: Added Resources *corev1.ResourceRequirements to ManagedJobParameters

  Observability

  - Prometheus metrics: Created controllers/metrics.go with counters (jobs created/succeeded/failed), histogram (reconciliation duration), and gauge (active jobs)
  - Structured logging: Added logger field to connPackage, used context-based logging throughout

  Configuration

  - Leader election ID: Made configurable via --leader-election-id flag
  - Development mode: Made configurable via --dev-mode flag and LOG_LEVEL env var

  Performance

  - Dependency lookup optimization: Changed from O(n*m) to O(1) using lookup maps (jobDepMap, groupDepMap)
  - Reconciliation backoff: Added RequeueAfter: 30*time.Second when workflow is running

  Documentation & Testing

  - Godoc documentation: Added comprehensive comments to API types and controller
  - Unit tests: Added helpers_test.go with tests for all helper functions
  - Integration tests: Added managedjob_controller_test.go with Ginkgo/Gomega tests

* Add the helm chart release.

* Add reasonable test coverage.
This commit is contained in:
2025-12-17 21:18:04 +00:00
parent b6ce5b7c98
commit 2b36071647
43 changed files with 16182 additions and 8179 deletions
+26 -18
View File
@@ -1,29 +1,37 @@
apiVersion: v2
name: jobs-manager
description: Kubernetes jobs manager operator
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
description: Kubernetes jobs manager operator for orchestrating workflow-based job execution with dependency management
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.33
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.0.33"
version: 0.0.34
appVersion: "0.0.34"
keywords:
- operator
- jobs
- tasks
- workflow
- kubernetes
- batch
home: https://raczylo.com
sources:
- https://github.com/lukaszraczylo/jobs-manager-operator
maintainers:
- name: lukaszraczylo
email: job-manager-operator@raczylo.com
annotations:
artifacthub.io/changes: |
- kind: added
description: Prometheus metrics support (jobs created/succeeded/failed, active jobs, reconciliation duration)
- kind: added
description: Configurable leader election ID via --leader-election-id flag
- kind: added
description: Configurable development logging mode via --dev-mode flag
- kind: added
description: LOG_LEVEL environment variable support
- kind: added
description: Finalizers for proper resource cleanup
- kind: added
description: Resource limits support for job containers
- kind: added
description: Reconciliation backoff/requeue logic
- kind: improved
description: O(1) dependency lookup performance optimization
@@ -53,12 +53,23 @@ spec:
10 }}
securityContext: {{- toYaml .Values.controllerManager.kubeRbacProxy.containerSecurityContext
| nindent 10 }}
- args: {{- toYaml .Values.controllerManager.manager.args | nindent 8 }}
- args:
{{- toYaml .Values.controllerManager.manager.args | nindent 8 }}
{{- if .Values.controllerManager.manager.leaderElectionId }}
- --leader-election-id={{ .Values.controllerManager.manager.leaderElectionId }}
{{- end }}
{{- if .Values.controllerManager.manager.devMode }}
- --dev-mode
{{- end }}
command:
- /manager
env:
- name: KUBERNETES_CLUSTER_DOMAIN
value: {{ quote .Values.kubernetesClusterDomain }}
{{- if .Values.controllerManager.manager.env.LOG_LEVEL }}
- name: LOG_LEVEL
value: {{ quote .Values.controllerManager.manager.env.LOG_LEVEL }}
{{- end }}
image: {{ .Values.controllerManager.manager.image.repository }}:{{ .Values.controllerManager.manager.image.tag | default .Chart.AppVersion }}
livenessProbe:
httpGet:
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,31 @@
{{- if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "chart.fullname" . }}-metrics
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ .Values.serviceMonitor.namespace }}
{{- end }}
labels:
{{- include "chart.labels" . | nindent 4 }}
{{- with .Values.serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
- path: /metrics
port: https
scheme: https
interval: {{ .Values.serviceMonitor.interval }}
scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
tlsConfig:
insecureSkipVerify: true
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
control-plane: controller-manager
{{- include "chart.selectorLabels" . | nindent 6 }}
{{- end }}
+25 -1
View File
@@ -21,10 +21,19 @@ controllerManager:
cpu: 5m
memory: 64Mi
manager:
# Command line arguments for the manager
args:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
# Leader election ID - customize for multi-tenant clusters
leaderElectionId: "jobsmanager.raczylo.com"
# Enable development mode with verbose logging (console format)
devMode: false
# Environment variables for the manager container
env:
# Set to "debug" to enable verbose logging
LOG_LEVEL: ""
containerSecurityContext:
allowPrivilegeEscalation: false
capabilities:
@@ -32,7 +41,7 @@ controllerManager:
- ALL
image:
repository: ghcr.io/lukaszraczylo/jobs-manager-operator
tag: 0.0.33
tag: "0.0.34"
resources:
limits:
cpu: 500m
@@ -43,7 +52,10 @@ controllerManager:
replicas: 1
serviceAccount:
annotations: {}
kubernetesClusterDomain: cluster.local
# Metrics service configuration
metricsService:
ports:
- name: https
@@ -51,3 +63,15 @@ metricsService:
protocol: TCP
targetPort: https
type: ClusterIP
# ServiceMonitor for Prometheus Operator integration
serviceMonitor:
enabled: false
# Namespace where ServiceMonitor will be created (defaults to release namespace)
namespace: ""
# Additional labels for ServiceMonitor
labels: {}
# Scrape interval
interval: 30s
# Scrape timeout
scrapeTimeout: 10s