🧱(helm) run clean files command as cronjob

Updates the help chart to be able to run a list of CronJobs.
By defaults it runs the clean_pending_files
and purge_deleted_files commands during the night.
This commit is contained in:
Florent Chehab
2026-06-03 17:58:02 +02:00
parent 5c15140783
commit 7b7951a0e0
3 changed files with 134 additions and 1 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
apiVersion: v2
type: application
name: meet
version: 0.0.23
version: 0.0.24
@@ -0,0 +1,108 @@
{{- if .Values.backend.cronjobs -}}
{{- $envVars := include "meet.common.env" (list . .Values.backend) -}}
{{- $fullName := include "meet.backend.fullname" . -}}
{{- $component := "backend-cronjob-list" -}}
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 "meet.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 "meet.secret.dockerconfigjson.name" (dict "fullname" (include "meet.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 "meet.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 }}
+25
View File
@@ -279,6 +279,31 @@ backend:
python manage.py createsuperuser --email $DJANGO_SUPERUSER_EMAIL --password $DJANGO_SUPERUSER_PASSWORD
restartPolicy: Never
## @section Jobs
## Schedule jobs at fixed times (like cron)
## Each cron job can be configured with name, schedule time and command.
## @param backend.cronjobs[0].name Name of the CronJob
## @param backend.cronjobs[0].schedule Schedule in cron format
## @param backend.cronjobs[0].command The bash command to execute in the CronJob
## @param backend.cronjobs[1].name Name of the CronJob
## @param backend.cronjobs[1].schedule Schedule in cron format
## @param backend.cronjobs[1].command The bash command to execute in the CronJob
cronjobs:
- name: clean-pending-files
schedule: "30 0 * * *"
command:
- "/bin/sh"
- "-c"
- "python manage.py clean_pending_files"
- name: purge-deleted-files
schedule: "45 0 * * *"
command:
- "/bin/sh"
- "-c"
- "python manage.py purge_deleted_files"
## @param backend.mergeDuplicateUsers.command backend merge_duplicate_users command
## @param backend.mergeDuplicateUsers.restartPolicy backend merge_duplicate_users job restart policy
mergeDuplicateUsers: