Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
helm: add optional cron job to run tootctl remove media (mastodon#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
dunn authored Oct 12, 2020
1 parent 9676175 commit 53b22d2
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
73 changes: 73 additions & 0 deletions chart/templates/cronjob-media-remove.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{ if .Values.cron.removeMedia.enabled }}
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: {{ include "mastodon.fullname" . }}-media-remove
labels:
{{- include "mastodon.labels" . | nindent 4 }}
spec:
schedule: {{ .Values.cron.removeMedia.schedule }}
jobTemplate:
spec:
template:
metadata:
name: {{ include "mastodon.fullname" . }}-media-remove
spec:
restartPolicy: OnFailure
# ensure we run on the same node as the other rails components; only
# required when using PVCs that are ReadWriteOnce
{{- if or (eq "ReadWriteOnce" .Values.persistence.assets.accessMode) (eq "ReadWriteOnce" .Values.persistence.system.accessMode) }}
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: component
operator: In
values:
- rails
topologyKey: kubernetes.io/hostname
{{- end }}
volumes:
- name: assets
persistentVolumeClaim:
claimName: {{ template "mastodon.fullname" . }}-assets
- name: system
persistentVolumeClaim:
claimName: {{ template "mastodon.fullname" . }}-system
containers:
- name: {{ include "mastodon.fullname" . }}-media-remove
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- bin/tootctl
- media
- remove
envFrom:
- configMapRef:
name: {{ include "mastodon.fullname" . }}-env
- secretRef:
name: {{ template "mastodon.fullname" . }}
env:
- name: "DB_PASS"
valueFrom:
secretKeyRef:
{{- if .Values.postgresql.enabled }}
name: {{ .Release.Name }}-postgresql
{{- else }}
name: {{ template "mastodon.fullname" . }}
{{- end }}
key: postgresql-password
- name: "REDIS_PASSWORD"
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-redis
key: redis-password
- name: "PORT"
value: {{ .Values.application.web.port | quote }}
volumeMounts:
- name: assets
mountPath: /opt/mastodon/public/assets
- name: system
mountPath: /opt/mastodon/public/system
{{- end }}
6 changes: 6 additions & 0 deletions chart/values.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ createAdmin:
# available locales: https://github.com/tootsuite/mastodon/blob/master/config/application.rb#L43
locale: en

cron:
# run `tootctl media remove` every week
removeMedia:
enabled: true
schedule: "0 0 * * 0"

application:
web:
port: 3000
Expand Down

0 comments on commit 53b22d2

Please sign in to comment.