|
| 1 | +{{/* Closed rendering foundation for typed Buzz operator jobs. */}} |
| 2 | + |
| 3 | +{{- define "buzz.operatorCronJob" -}} |
| 4 | +{{- $root := .root -}} |
| 5 | +{{- if eq .type "deletionDrain" -}} |
| 6 | +{{- $job := $root.Values.operatorJobs.deletionDrain -}} |
| 7 | +{{- range $label := list "app.kubernetes.io/name" "app.kubernetes.io/instance" "app.kubernetes.io/component" -}} |
| 8 | +{{- if hasKey $job.podLabels $label -}} |
| 9 | +{{- fail (printf "operatorJobs.deletionDrain.podLabels may not set chart-owned label %q" $label) -}} |
| 10 | +{{- end -}} |
| 11 | +{{- end -}} |
| 12 | +apiVersion: batch/v1 |
| 13 | +kind: CronJob |
| 14 | +metadata: |
| 15 | + name: {{ include "buzz.cronJobName" (dict "root" $root "suffix" "deletion-drain") }} |
| 16 | + labels: |
| 17 | + {{- include "buzz.labels" $root | nindent 4 }} |
| 18 | + app.kubernetes.io/component: deletion-drain |
| 19 | +spec: |
| 20 | + schedule: {{ $job.schedule | quote }} |
| 21 | + concurrencyPolicy: Forbid |
| 22 | + successfulJobsHistoryLimit: {{ $job.successfulJobsHistoryLimit }} |
| 23 | + failedJobsHistoryLimit: {{ $job.failedJobsHistoryLimit }} |
| 24 | + jobTemplate: |
| 25 | + spec: |
| 26 | + activeDeadlineSeconds: {{ $job.activeDeadlineSeconds }} |
| 27 | + backoffLimit: 0 |
| 28 | + template: |
| 29 | + metadata: |
| 30 | + labels: |
| 31 | + {{- include "buzz.selectorLabels" $root | nindent 12 }} |
| 32 | + app.kubernetes.io/component: deletion-drain |
| 33 | + {{- with $job.podLabels }} |
| 34 | + {{- toYaml . | nindent 12 }} |
| 35 | + {{- end }} |
| 36 | + annotations: |
| 37 | + {{- toYaml $job.podAnnotations | nindent 12 }} |
| 38 | + spec: |
| 39 | + restartPolicy: Never |
| 40 | + terminationGracePeriodSeconds: {{ $job.terminationGracePeriodSeconds }} |
| 41 | + serviceAccountName: {{ default (include "buzz.serviceAccountName" $root) $job.serviceAccountName }} |
| 42 | + automountServiceAccountToken: false |
| 43 | + enableServiceLinks: false |
| 44 | + securityContext: |
| 45 | + {{- toYaml $root.Values.relay.securityContext | nindent 12 }} |
| 46 | + {{- with $root.Values.image.pullSecrets }} |
| 47 | + imagePullSecrets: |
| 48 | + {{- toYaml . | nindent 12 }} |
| 49 | + {{- end }} |
| 50 | + containers: |
| 51 | + - name: deletion-drain |
| 52 | + image: {{ include "buzz.image" $root }} |
| 53 | + imagePullPolicy: {{ $root.Values.image.pullPolicy }} |
| 54 | + securityContext: |
| 55 | + {{- omit $root.Values.relay.containerSecurityContext "readOnlyRootFilesystem" | toYaml | nindent 16 }} |
| 56 | + readOnlyRootFilesystem: true |
| 57 | + command: ["/usr/local/bin/buzz-admin"] |
| 58 | + args: ["deletions", "drain"] |
| 59 | + env: |
| 60 | + - { name: BUZZ_S3_ENDPOINT, value: {{ required "s3.endpoint is required when operatorJobs.deletionDrain.enabled=true" (include "buzz.s3Endpoint" $root) | quote }} } |
| 61 | + - { name: BUZZ_S3_BUCKET, value: {{ required "s3.bucket is required when operatorJobs.deletionDrain.enabled=true" $root.Values.s3.bucket | quote }} } |
| 62 | + - { name: BUZZ_S3_REGION, value: {{ $root.Values.s3.region | quote }} } |
| 63 | + - { name: BUZZ_S3_ADDRESSING_STYLE, value: {{ $root.Values.s3.addressingStyle | quote }} } |
| 64 | + - name: DATABASE_URL |
| 65 | + valueFrom: |
| 66 | + secretKeyRef: |
| 67 | + name: {{ include "buzz.envSecretName" $root }} |
| 68 | + key: DATABASE_URL |
| 69 | + - name: REDIS_URL |
| 70 | + valueFrom: |
| 71 | + secretKeyRef: |
| 72 | + name: {{ include "buzz.envSecretName" $root }} |
| 73 | + key: REDIS_URL |
| 74 | + - name: BUZZ_S3_ACCESS_KEY |
| 75 | + valueFrom: |
| 76 | + secretKeyRef: |
| 77 | + name: {{ include "buzz.envSecretName" $root }} |
| 78 | + key: BUZZ_S3_ACCESS_KEY |
| 79 | + optional: true |
| 80 | + - name: BUZZ_S3_SECRET_KEY |
| 81 | + valueFrom: |
| 82 | + secretKeyRef: |
| 83 | + name: {{ include "buzz.envSecretName" $root }} |
| 84 | + key: BUZZ_S3_SECRET_KEY |
| 85 | + optional: true |
| 86 | + resources: |
| 87 | + {{- toYaml $job.resources | nindent 16 }} |
| 88 | +{{- else -}} |
| 89 | +{{- fail (printf "unsupported typed operator job %q" .type) -}} |
| 90 | +{{- end -}} |
| 91 | +{{- end -}} |
0 commit comments