Skip to content

Commit

Permalink
[xy] Add cleanup job to helm chart.
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxiaoyou1993 committed Dec 14, 2024
1 parent f03d00f commit d9596e9
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
46 changes: 46 additions & 0 deletions charts/mageai/templates/cleanup-cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{- if .Values.cleanupJob.enabled -}}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "mageai.fullname" . }}-cleanup-job
spec:
schedule: "0 * * * *" # Runs every hour
jobTemplate:
spec:
template:
spec:
containers:
- name: mage-cleanup
{{- if .Values.image.digest }}
image: "{{ .Values.image.repository }}@{{ .Values.image.digest }}"
{{- else }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
{{- end }}
command:
- /bin/sh
- -c
- |
repo_name="${USER_CODE_PATH:-default_repo}" &&
mage clean-cached-variables "$repo_name" &&
mage clean-old-logs "$repo_name"
env:
{{- if .Values.env }}
{{- toYaml .Values.env | nindent 16 }}
{{- else if .Values.extraEnvs }}
{{- toYaml .Values.extraEnvs | nindent 16 }}
{{- end }}
volumeMounts:
{{- if .Values.volumes }}
- name: mage-fs
mountPath: /home/src
{{- else if .Values.extraVolumeMounts }}
{{- toYaml .Values.extraVolumeMounts | nindent 16 }}
{{- end }}
restartPolicy: OnFailure
volumes:
{{- if .Values.volumes }}
{{- toYaml .Values.volumes | nindent 12 }}
{{- else if .Values.extraVolumes -}}
{{ toYaml .Values.extraVolumes | nindent 12 }}
{{- end }}
{{- end }}
3 changes: 3 additions & 0 deletions charts/mageai/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,6 @@ extraEnvs:
valueFrom:
fieldRef:
fieldPath: metadata.namespace

cleanupJob:
enabled: false

0 comments on commit d9596e9

Please sign in to comment.