mirror of
https://github.com/lukaszraczylo/jobs-manager-operator.git
synced 2026-10-13 05:39:41 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c99558314c | ||
|
|
56edfc8d8c
|
||
|
|
5c92083161
|
||
|
|
60cb552179
|
||
|
|
9d3086c839
|
||
|
|
6189a2e2f3
|
@@ -0,0 +1 @@
|
||||
* lukaszraczylo
|
||||
@@ -145,6 +145,41 @@ In this case - result for the first job will look like this:
|
||||
status: succeeded
|
||||
```
|
||||
|
||||
### Available params
|
||||
|
||||
There's quite a lot of of flexibility with parameters. On every level where params are allowed, you can define:
|
||||
|
||||
```yaml
|
||||
params:
|
||||
fromEnv:
|
||||
- configMapRef:
|
||||
name: "configmap-name"
|
||||
key: "key-name"
|
||||
env:
|
||||
- name: "FOO"
|
||||
value: "bar"
|
||||
volumes:
|
||||
- name: secrets-store-api
|
||||
csi:
|
||||
driver: secrets-store.csi.k8s.io
|
||||
readOnly: true
|
||||
volumeAttributes:
|
||||
secretProviderClass: api-secrets-provider
|
||||
volumeMount:
|
||||
- name: secrets-store-api
|
||||
mountPath: "/mnt/secrets-api"
|
||||
readOnly: true
|
||||
serviceAccount: "service-account-name"
|
||||
restartPolicy: "Never"
|
||||
imagePullSecrets:
|
||||
- "ghcr-token"
|
||||
imagePullPolicy:
|
||||
- "Always"
|
||||
labels:
|
||||
"label-name": "label-value"
|
||||
```
|
||||
|
||||
|
||||
### Kustomization and references
|
||||
|
||||
In case of any issues with `configmapGenerator` or `secretGenerator`, please add following to your `kustomization.yaml`:
|
||||
|
||||
@@ -94,6 +94,8 @@ type ManagedJobParameters struct {
|
||||
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
|
||||
// +kubebuilder:validation:Optional
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
// +kubebuilder:validation:Optional
|
||||
Annotations map[string]string `json:"annotations,omitempty"`
|
||||
}
|
||||
|
||||
// ManagedJobSpec defines the desired state of ManagedJob
|
||||
|
||||
@@ -213,6 +213,13 @@ func (in *ManagedJobParameters) DeepCopyInto(out *ManagedJobParameters) {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.Annotations != nil {
|
||||
in, out := &in.Annotations, &out.Annotations
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedJobParameters.
|
||||
|
||||
@@ -13,12 +13,12 @@ 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.17
|
||||
version: 0.0.21
|
||||
# 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.17"
|
||||
appVersion: "0.0.21"
|
||||
keywords:
|
||||
- operator
|
||||
- jobs
|
||||
|
||||
@@ -59,6 +59,10 @@ spec:
|
||||
type: array
|
||||
compiledParams:
|
||||
properties:
|
||||
annotations:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
env:
|
||||
items:
|
||||
description: EnvVar represents an environment variable
|
||||
@@ -2135,6 +2139,10 @@ spec:
|
||||
type: boolean
|
||||
params:
|
||||
properties:
|
||||
annotations:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
env:
|
||||
items:
|
||||
description: EnvVar represents an environment variable
|
||||
@@ -4205,6 +4213,10 @@ spec:
|
||||
type: boolean
|
||||
params:
|
||||
properties:
|
||||
annotations:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
env:
|
||||
items:
|
||||
description: EnvVar represents an environment variable present
|
||||
@@ -6131,6 +6143,10 @@ spec:
|
||||
type: array
|
||||
params:
|
||||
properties:
|
||||
annotations:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
env:
|
||||
items:
|
||||
description: EnvVar represents an environment variable present
|
||||
|
||||
@@ -13,7 +13,7 @@ controllerManager:
|
||||
manager:
|
||||
image:
|
||||
repository: ghcr.io/lukaszraczylo/jobs-manager-operator
|
||||
tag: 0.0.17
|
||||
tag: {{ .Chart.AppVersion }}
|
||||
resources:
|
||||
limits:
|
||||
cpu: 500m
|
||||
|
||||
@@ -59,6 +59,10 @@ spec:
|
||||
type: array
|
||||
compiledParams:
|
||||
properties:
|
||||
annotations:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
env:
|
||||
items:
|
||||
description: EnvVar represents an environment variable
|
||||
@@ -2205,6 +2209,10 @@ spec:
|
||||
type: boolean
|
||||
params:
|
||||
properties:
|
||||
annotations:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
env:
|
||||
items:
|
||||
description: EnvVar represents an environment variable
|
||||
@@ -4345,6 +4353,10 @@ spec:
|
||||
type: boolean
|
||||
params:
|
||||
properties:
|
||||
annotations:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
env:
|
||||
items:
|
||||
description: EnvVar represents an environment variable
|
||||
@@ -6317,6 +6329,10 @@ spec:
|
||||
type: array
|
||||
params:
|
||||
properties:
|
||||
annotations:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
env:
|
||||
items:
|
||||
description: EnvVar represents an environment variable present
|
||||
|
||||
@@ -118,6 +118,7 @@ func (cp *connPackage) generateDependencyTree() {
|
||||
groupTree := mainTree.Add(group.Name)
|
||||
for _, job := range group.Jobs {
|
||||
jobTree := groupTree.Add(job.Name)
|
||||
job.CompiledParams = cp.compileParameters(cp.mj.Spec.Params, group.Params, job.Params)
|
||||
if job.Parallel {
|
||||
continue
|
||||
} else {
|
||||
@@ -130,7 +131,6 @@ func (cp *connPackage) generateDependencyTree() {
|
||||
jobTree.Add("Depends on: " + generatedJobName)
|
||||
if !cp.checkIfPresentInDependencies(job.Dependencies, generatedJobName) {
|
||||
job.Dependencies = append(job.Dependencies, &jobsmanagerv1beta1.ManagedJobDependencies{Name: generatedJobName, Status: ExecutionStatusPending})
|
||||
job.CompiledParams = cp.compileParameters(cp.mj.Spec.Params, group.Params, job.Params)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ type compiledParams struct {
|
||||
ImagePullSecrets []corev1.LocalObjectReference
|
||||
ImagePullPolicy string
|
||||
Labels map[string]string
|
||||
Annotations map[string]string
|
||||
}
|
||||
|
||||
func (cp *connPackage) compileParameters(params ...jobsmanagerv1beta1.ManagedJobParameters) jobsmanagerv1beta1.ManagedJobParameters {
|
||||
@@ -56,6 +57,11 @@ func (cp *connPackage) compileParameters(params ...jobsmanagerv1beta1.ManagedJob
|
||||
cparams.Labels[k] = v
|
||||
}
|
||||
}
|
||||
if params.Annotations != nil {
|
||||
for k, v := range params.Annotations {
|
||||
cparams.Annotations[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return cparams
|
||||
@@ -242,6 +248,12 @@ func (cp *connPackage) executeJob(j *jobsmanagerv1beta1.ManagedJobDefinition, g
|
||||
labels[k] = v
|
||||
}
|
||||
|
||||
annotations := map[string]string{}
|
||||
|
||||
for k, v := range j.CompiledParams.Annotations {
|
||||
annotations[k] = v
|
||||
}
|
||||
|
||||
job_handler := kbatch.Job{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: generatedJobName,
|
||||
@@ -250,9 +262,10 @@ func (cp *connPackage) executeJob(j *jobsmanagerv1beta1.ManagedJobDefinition, g
|
||||
Spec: kbatch.JobSpec{
|
||||
Template: corev1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: generatedJobName,
|
||||
Namespace: cp.mj.Namespace,
|
||||
Labels: labels,
|
||||
Name: generatedJobName,
|
||||
Namespace: cp.mj.Namespace,
|
||||
Labels: labels,
|
||||
Annotations: annotations,
|
||||
},
|
||||
Spec: corev1.PodSpec{
|
||||
Volumes: j.CompiledParams.Volumes,
|
||||
|
||||
@@ -60,12 +60,18 @@ func (r *ManagedJobReconciler) Reconcile(ctx context.Context, req ctrl.Request)
|
||||
|
||||
originalMainJobDefinition := cp.mj.DeepCopy()
|
||||
cp.generateDependencyTree()
|
||||
_, theSame, _ := pandati.CompareStructsReplaced(originalMainJobDefinition, cp.mj)
|
||||
if !theSame {
|
||||
cp.updateCRDStatusDirectly()
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
originalMainJobDefinition = cp.mj.DeepCopy()
|
||||
|
||||
// TODO: Re-enable after testing
|
||||
cp.checkRunningJobsStatus()
|
||||
cp.runPendingJobs()
|
||||
|
||||
_, theSame, _ := pandati.CompareStructsReplaced(originalMainJobDefinition, cp.mj)
|
||||
_, theSame, _ = pandati.CompareStructsReplaced(originalMainJobDefinition, cp.mj)
|
||||
if !theSame {
|
||||
cp.updateCRDStatusDirectly()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user