Skip to content

Commit

Permalink
charts: support cronjob for periodic maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
ushitora-anqou committed Oct 19, 2024
1 parent 2f98672 commit e45f637
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
56 changes: 56 additions & 0 deletions charts/magout/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{- if .Values.periodicMaintenance.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "magout.fullname" . }}-cleanup
spec:
concurrencyPolicy: Forbid
jobTemplate:
spec:
template:
spec:
containers:
- command:
- bash
- -xeu
- -c
- |
{{- if .Values.periodicMaintenance.removeStatuses.enabled }}
bin/tootctl statuses remove
{{- end }}
{{- if .Values.periodicMaintenance.pruneAccounts.enabled }}
bin/tootctl accounts prune
{{- end }}
{{- if .Values.periodicMaintenance.cullAccounts.enabled }}
bin/tootctl accounts cull
{{- end }}
{{- if .Values.periodicMaintenance.removeMedia.enabled }}
bin/tootctl media remove
{{- end }}
{{- if .Values.periodicMaintenance.pruneProfileMedia.enabled }}
bin/tootctl media remove --prune-profiles
{{- end }}
{{- if .Values.periodicMaintenance.removePreviewCards.enabled }}
bin/tootctl preview_cards remove
{{- end }}
{{- if .Values.periodicMaintenance.removeOrphanMedia.enabled }}
bin/tootctl media remove-orphans
{{- end }}
{{- if .Values.periodicMaintenance.refreshAccounts.enabled }}
bin/tootctl accounts refresh --all
{{- end }}
{{- with .Values.periodicMaintenance.envFrom }}
envFrom:
{{- toYaml . | nindent 14 }}
{{- end }}
image: {{ .Values.mastodonVersion.image }}
name: tootctl
{{- with .Values.periodicMaintenance.resources }}
resources:
{{- toYaml . | nindent 14 }}
{{- end }}
restartPolicy: Never
schedule: {{ .Values.periodicMaintenance.schedule }}
timeZone: {{ .Values.periodicMaintenance.timeZone }}
successfulJobsHistoryLimit: {{ .Values.periodicMaintenance.successfulJobsHistoryLimit }}
{{- end }}
24 changes: 24 additions & 0 deletions charts/magout/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,27 @@ ingress:
ingressClassName: ""
tls:
enabled: false

periodicMaintenance:
enabled: true
schedule: "0 0 * * *"
timeZone: "UTC"
successfulJobsHistoryLimit: 1
envFrom: {}
resources: {}
removeStatuses: # tootctl statuses remove
enabled: false
pruneAccounts: # tootctl accounts prune
enabled: true
cullAccounts: # tootctl accounts cull
enabled: true
removeMedia: # tootctl media remove
enabled: true
pruneProfileMedia: # tootctl media remove --prune-profiles
enabled: false
removeOrphanMedia: # tootctl media remove-orphans
enabled: false
refreshAccounts: # tootctl accounts refresh --all
enabled: false
removePreviewCards: # tootctl preview_cards remove
enabled: false

0 comments on commit e45f637

Please sign in to comment.