diff --git a/charts/mageai/Chart.yaml b/charts/mageai/Chart.yaml index f1a5a44..a2057cb 100644 --- a/charts/mageai/Chart.yaml +++ b/charts/mageai/Chart.yaml @@ -76,4 +76,4 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.2.6 +version: 0.2.7 diff --git a/charts/mageai/templates/cleanup-cronjob.yaml b/charts/mageai/templates/cleanup-cronjob.yaml new file mode 100644 index 0000000..5da91df --- /dev/null +++ b/charts/mageai/templates/cleanup-cronjob.yaml @@ -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 }} diff --git a/charts/mageai/values.yaml b/charts/mageai/values.yaml index 9b460aa..e17561a 100644 --- a/charts/mageai/values.yaml +++ b/charts/mageai/values.yaml @@ -209,3 +209,6 @@ extraEnvs: valueFrom: fieldRef: fieldPath: metadata.namespace + +cleanupJob: + enabled: false