From 7b7951a0e0105b787697cd0a0a7e0a32514e881c Mon Sep 17 00:00:00 2001 From: Florent Chehab Date: Wed, 3 Jun 2026 17:58:02 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B1(helm)=20run=20clean=20files=20comm?= =?UTF-8?q?and=20as=20cronjob?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/helm/meet/Chart.yaml | 2 +- .../meet/templates/backend_cronjob_list.yaml | 108 ++++++++++++++++++ src/helm/meet/values.yaml | 25 ++++ 3 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 src/helm/meet/templates/backend_cronjob_list.yaml diff --git a/src/helm/meet/Chart.yaml b/src/helm/meet/Chart.yaml index 1c86198e..fa58d404 100644 --- a/src/helm/meet/Chart.yaml +++ b/src/helm/meet/Chart.yaml @@ -1,4 +1,4 @@ apiVersion: v2 type: application name: meet -version: 0.0.23 +version: 0.0.24 diff --git a/src/helm/meet/templates/backend_cronjob_list.yaml b/src/helm/meet/templates/backend_cronjob_list.yaml new file mode 100644 index 00000000..ab4161f7 --- /dev/null +++ b/src/helm/meet/templates/backend_cronjob_list.yaml @@ -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 }} diff --git a/src/helm/meet/values.yaml b/src/helm/meet/values.yaml index 86a36898..f6634b6d 100644 --- a/src/helm/meet/values.yaml +++ b/src/helm/meet/values.yaml @@ -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: