✨(helm) allow to configure cronjobs using backend image
We want to configure cronjobs. Instead of declaring them one by one, we use a CronJobList, the will all have the same pattern, mostly the command and the schedule will change.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
apiVersion: v2
|
||||
type: application
|
||||
name: docs
|
||||
version: 3.4.0-beta.1
|
||||
version: 3.4.0-beta.2
|
||||
appVersion: latest
|
||||
|
||||
@@ -111,6 +111,7 @@
|
||||
| `backend.job.command` | The management command to execute | `[]` |
|
||||
| `backend.job.restartPolicy` | The restart policy for the job. | `Never` |
|
||||
| `backend.job.annotations` | Annotations to add to the job [default: argocd.argoproj.io/hook: PostSync] | |
|
||||
| `backend.cronjobs` | Cronjob name, schedule, command | `[]` |
|
||||
| `backend.probes.liveness.path` | Configure path for backend HTTP liveness probe | `/__heartbeat__` |
|
||||
| `backend.probes.liveness.targetPort` | Configure port for backend HTTP liveness probe | `undefined` |
|
||||
| `backend.probes.liveness.initialDelaySeconds` | Configure initial delay for backend liveness probe | `10` |
|
||||
|
||||
108
src/helm/impress/templates/backend_cronjob_list.yaml
Normal file
108
src/helm/impress/templates/backend_cronjob_list.yaml
Normal file
@@ -0,0 +1,108 @@
|
||||
{{- if .Values.backend.cronjobs -}}
|
||||
{{- $envVars := include "impress.common.env" (list . .Values.backend) -}}
|
||||
{{- $fullName := include "impress.backend.fullname" . -}}
|
||||
{{- $component := "backend" -}}
|
||||
apiVersion: batch/v1
|
||||
kind: CronJobList
|
||||
items:
|
||||
{{- range .Values.backend.cronjobs }}
|
||||
- apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: {{ $fullName }}-{{ .name }}
|
||||
namespace: {{ $.Release.Namespace | quote }}
|
||||
labels:
|
||||
{{- include "impress.common.labels" (list $ $component) | nindent 8 }}
|
||||
spec:
|
||||
schedule: {{ .schedule }}
|
||||
concurrencyPolicy: {{ .concurrencyPolicy | default "Forbid" }}
|
||||
successfulJobsHistoryLimit: {{ .successfulJobsHistoryLimit | default 3 }}
|
||||
failedJobsHistoryLimit: {{ .failedJobsHistoryLimit | default 1 }}
|
||||
jobTemplate:
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
name: {{ $fullName }}-{{ .name }}
|
||||
spec:
|
||||
{{- if $.Values.image.credentials }}
|
||||
imagePullSecrets:
|
||||
- name: {{ include "impress.secret.dockerconfigjson.name" (dict "fullname" (include "impress.fullname" .) "imageCredentials" $.Values.image.credentials) }}
|
||||
{{- end}}
|
||||
shareProcessNamespace: {{ $.Values.backend.shareProcessNamespace }}
|
||||
containers:
|
||||
{{- with $.Values.backend.sidecars }}
|
||||
{{- toYaml . | nindent 18 }}
|
||||
{{- end }}
|
||||
- name: {{ $.Chart.Name }}
|
||||
image: "{{ ($.Values.backend.image | default dict).repository | default $.Values.image.repository }}:{{ ($.Values.backend.image | default dict).tag | default $.Values.image.tag }}"
|
||||
imagePullPolicy: {{ ($.Values.backend.image | default dict).pullPolicy | default $.Values.image.pullPolicy }}
|
||||
args:
|
||||
{{- toYaml .command | nindent 22 }}
|
||||
env:
|
||||
{{- if $envVars}}
|
||||
{{- $envVars | indent 22 }}
|
||||
{{- end }}
|
||||
{{- with $.Values.backend.securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 22 }}
|
||||
{{- end }}
|
||||
{{- with $.Values.backend.resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 22 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
{{- range $index, $value := $.Values.mountFiles }}
|
||||
- name: "files-{{ $index }}"
|
||||
mountPath: {{ $value.path }}
|
||||
subPath: content
|
||||
{{- end }}
|
||||
{{- range $name, $volume := $.Values.backend.persistence }}
|
||||
- name: "{{ $name }}"
|
||||
mountPath: "{{ $volume.mountPath }}"
|
||||
{{- end }}
|
||||
{{- range $.Values.backend.extraVolumeMounts }}
|
||||
- name: {{ .name }}
|
||||
mountPath: {{ .mountPath }}
|
||||
subPath: {{ .subPath | default "" }}
|
||||
readOnly: {{ .readOnly }}
|
||||
{{- end }}
|
||||
restartPolicy: {{ .restartPolicy | default "Never" }}
|
||||
volumes:
|
||||
{{- range $index, $value := $.Values.mountFiles }}
|
||||
- name: "files-{{ $index }}"
|
||||
configMap:
|
||||
name: "{{ include "impress.fullname" $ }}-files-{{ $index }}"
|
||||
{{- end }}
|
||||
{{- range $name, $volume := $.Values.backend.persistence }}
|
||||
- name: "{{ $name }}"
|
||||
{{- if eq $volume.type "emptyDir" }}
|
||||
emptyDir: {}
|
||||
{{- else }}
|
||||
persistentVolumeClaim:
|
||||
claimName: "{{ $fullName }}-{{ $name }}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- range $.Values.backend.extraVolumes }}
|
||||
- name: {{ .name }}
|
||||
{{- if .existingClaim }}
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ .existingClaim }}
|
||||
{{- else if .hostPath }}
|
||||
hostPath:
|
||||
{{ toYaml .hostPath | nindent 22 }}
|
||||
{{- else if .csi }}
|
||||
csi:
|
||||
{{- toYaml .csi | nindent 22 }}
|
||||
{{- else if .configMap }}
|
||||
configMap:
|
||||
{{- toYaml .configMap | nindent 22 }}
|
||||
{{- else if .emptyDir }}
|
||||
emptyDir:
|
||||
{{- toYaml .emptyDir | nindent 22 }}
|
||||
{{- else }}
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -285,6 +285,17 @@ backend:
|
||||
annotations:
|
||||
argocd.argoproj.io/hook: PostSync
|
||||
|
||||
# List of cronjob to add
|
||||
# cronjobs:
|
||||
# - name: reset-database
|
||||
# schedule: "0 */2 * * *"
|
||||
# command:
|
||||
# - "/bin/sh"
|
||||
# - "-c"
|
||||
# - python manage.py flush --no-input
|
||||
## @param backend.cronjobs Cronjob name, schedule, command
|
||||
cronjobs: []
|
||||
|
||||
## @param backend.probes.liveness.path [nullable] Configure path for backend HTTP liveness probe
|
||||
## @param backend.probes.liveness.targetPort [nullable] Configure port for backend HTTP liveness probe
|
||||
## @param backend.probes.liveness.initialDelaySeconds [nullable] Configure initial delay for backend liveness probe
|
||||
|
||||
Reference in New Issue
Block a user