From bddaab694250aaa63ae994443777ab44149c45a4 Mon Sep 17 00:00:00 2001 From: Chi-En Wu Date: Mon, 20 Apr 2020 16:38:09 +0800 Subject: [PATCH] feat: add template `common.cronJob` --- templates/_cronjob.yaml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 templates/_cronjob.yaml diff --git a/templates/_cronjob.yaml b/templates/_cronjob.yaml new file mode 100644 index 0000000..c5c6651 --- /dev/null +++ b/templates/_cronjob.yaml @@ -0,0 +1,34 @@ +{{/* vim: set filetype=mustache: */}} + +{{- define "common.cronJob.pod" -}} +spec: + restartPolicy: OnFailure +{{- end -}} + +{{- define "common.cronJob.tpl" -}} +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + {{ include "common.metadata" . | nindent 2 }} +spec: + schedule: "{{ .Values.cronJob.schedule }}" + {{- with .Values.cronJob.concurrencyPolicy }} + concurrencyPolicy: {{ . }} + {{- end }} + {{- with .Values.cronJob.failedJobsHistoryLimit }} + failedJobsHistoryLimit: {{ . }} + {{- end }} + {{- with .Values.cronJob.successfulJobsHistoryLimit }} + successfulJobsHistoryLimit: {{ . }} + {{- end }} + jobTemplate: + metadata: + {{ include "common.metadata" . | nindent 6 }} + spec: + template: + {{ include "common.pod-template" (list . "common.cronJob.pod") | nindent 8 }} +{{- end -}} + +{{- define "common.cronJob" -}} +{{- include "common.utils.flattenCall" (list "common.utils.merge" . "common.cronJob.tpl") -}} +{{- end -}}