helm-charts/charts/library/common/templates/classes/_cronjob.tpl
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs b360c9885a
feat(common): Release v2.1.0 (#221)
Co-authored-by: Christopher Larivière <lariviere.c@gmail.com>
2023-11-10 15:46:55 +01:00

58 lines
2.2 KiB
Smarty

{{/*
This template serves as a blueprint for Cronjob objects that are created
using the common library.
*/}}
{{- define "bjw-s.common.class.cronjob" -}}
{{- $rootContext := .rootContext -}}
{{- $cronjobObject := .object -}}
{{- $timeZone := "" -}}
{{- if ge (int $rootContext.Capabilities.KubeVersion.Minor) 27 }}
{{- $timeZone = dig "cronjob" "timeZone" "" $cronjobObject -}}
{{- end -}}
{{- $labels := merge
(dict "app.kubernetes.io/component" $cronjobObject.identifier)
($cronjobObject.labels | default dict)
(include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml)
-}}
{{- $annotations := merge
($cronjobObject.annotations | default dict)
(include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml)
-}}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ $cronjobObject.name }}
{{- with $labels }}
labels: {{- toYaml . | nindent 4 -}}
{{- end }}
{{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}}
{{- end }}
spec:
concurrencyPolicy: "{{ $cronjobObject.cronjob.concurrencyPolicy }}"
startingDeadlineSeconds: {{ $cronjobObject.cronjob.startingDeadlineSeconds }}
{{- with $timeZone }}
timeZone: "{{ . }}"
{{- end }}
schedule: "{{ $cronjobObject.cronjob.schedule }}"
successfulJobsHistoryLimit: {{ $cronjobObject.cronjob.successfulJobsHistory }}
failedJobsHistoryLimit: {{ $cronjobObject.cronjob.failedJobsHistory }}
jobTemplate:
spec:
{{- with $cronjobObject.cronjob.ttlSecondsAfterFinished }}
ttlSecondsAfterFinished: {{ . }}
{{- end }}
backoffLimit: {{ $cronjobObject.cronjob.backoffLimit }}
template:
metadata:
{{- with (include "bjw-s.common.lib.pod.metadata.annotations" (dict "rootContext" $rootContext "controllerObject" $cronjobObject)) }}
annotations: {{ . | nindent 12 }}
{{- end -}}
{{- with (include "bjw-s.common.lib.pod.metadata.labels" (dict "rootContext" $rootContext "controllerObject" $cronjobObject)) }}
labels: {{ . | nindent 12 }}
{{- end }}
spec: {{ include "bjw-s.common.lib.pod.spec" (dict "rootContext" $rootContext "controllerObject" $cronjobObject) | nindent 10 }}
{{- end -}}