Browse Source

better annotations

tags/0.0.7
Vladimir Smagin 1 month ago
parent
commit
a7c12a57e4
3 changed files with 24 additions and 3 deletions
  1. +21
    -1
      README.md
  2. +1
    -0
      pkg/apis/blindage/v1alpha1/cronop_types.go
  3. +2
    -2
      pkg/controller/cronop/cronjob.go

+ 21
- 1
README.md View File

@@ -90,7 +90,27 @@ Global resource limiting also kubernetes standard, but separated:

Operator automatically copies labels from CR _meta_ to Cronjob, Job and Pod.

Also you cat set `annotations` in CR _spec_ to set it for Pod.
Also you cat set `annotations` in CR _spec_ to set it for Pod and merge it with individual task annotations:

```
---
apiVersion: blindage.org/v1alpha1
kind: CronOp
metadata:
name: mycron
spec:
image: "python:3"
annotations:
co.elastic.logs.backup/multiline.match: after
co.elastic.logs.backup/multiline.negate: "true"
co.elastic.logs.backup/multiline.pattern: ^\[
tasks:
- name: print-test
annotations:
logger: do-not-log
commands: ['python','-c', 'print("doing nothing")']
schedule: "* * * * *"
```

## Your first CronOp deployment



+ 1
- 0
pkg/apis/blindage/v1alpha1/cronop_types.go View File

@@ -19,6 +19,7 @@ type CronTask struct {
EnvConfigmap string `json:"envConfigmap,omitempty"` // default empty, overrides global configmap
BackoffLimit *int32 `json:"backoffLimit,omitempty"` // default 0, overrides global limit
PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` // default empty, overrides global context
Annotations map[string]string `json:"annotations,omitempty"` // annotations for pod

// Use it if you want provide some secrets or config files
MountConfigmap string `json:"mountConfigmap,omitempty"` // Mount configmap as files, default empty


+ 2
- 2
pkg/controller/cronop/cronjob.go View File

@@ -45,8 +45,8 @@ func generateCronjob(reqLogger logr.Logger, cr *blindagev1alpha1.CronOp, jobSpec
cronjob.Spec.JobTemplate.ObjectMeta.Labels = mergeMaps(baseLabels, cr.ObjectMeta.Labels)
cronjob.Spec.JobTemplate.Spec.Template.ObjectMeta.Labels = mergeMaps(baseLabels, cr.ObjectMeta.Labels)

// set annotation for template
cronjob.Spec.JobTemplate.Spec.Template.ObjectMeta.Annotations = cr.Spec.Annotations
// set annotations for template
cronjob.Spec.JobTemplate.Spec.Template.ObjectMeta.Annotations = mergeMaps(cr.Spec.Annotations, jobSpec.Annotations)

cronjob.Spec.Schedule = "0 * * * *"
if jobSpec.Schedule != "" {


Loading…
Cancel
Save