cronjob-media-remove.yaml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. {{ if .Values.mastodon.cron.removeMedia.enabled -}}
  2. apiVersion: batch/v1
  3. kind: CronJob
  4. metadata:
  5. name: {{ include "mastodon.fullname" . }}-media-remove
  6. labels:
  7. {{- include "mastodon.labels" . | nindent 4 }}
  8. spec:
  9. schedule: {{ .Values.mastodon.cron.removeMedia.schedule }}
  10. jobTemplate:
  11. spec:
  12. template:
  13. metadata:
  14. name: {{ include "mastodon.fullname" . }}-media-remove
  15. {{- with .Values.jobAnnotations }}
  16. annotations:
  17. {{- toYaml . | nindent 12 }}
  18. {{- end }}
  19. spec:
  20. restartPolicy: OnFailure
  21. {{- if (not .Values.mastodon.s3.enabled) }}
  22. # ensure we run on the same node as the other rails components; only
  23. # required when using PVCs that are ReadWriteOnce
  24. {{- if or (eq "ReadWriteOnce" .Values.mastodon.persistence.assets.accessMode) (eq "ReadWriteOnce" .Values.mastodon.persistence.system.accessMode) }}
  25. affinity:
  26. podAffinity:
  27. requiredDuringSchedulingIgnoredDuringExecution:
  28. - labelSelector:
  29. matchExpressions:
  30. - key: app.kubernetes.io/part-of
  31. operator: In
  32. values:
  33. - rails
  34. topologyKey: kubernetes.io/hostname
  35. {{- end }}
  36. volumes:
  37. - name: assets
  38. persistentVolumeClaim:
  39. claimName: {{ template "mastodon.fullname" . }}-assets
  40. - name: system
  41. persistentVolumeClaim:
  42. claimName: {{ template "mastodon.fullname" . }}-system
  43. {{- end }}
  44. containers:
  45. - name: {{ include "mastodon.fullname" . }}-media-remove
  46. image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
  47. imagePullPolicy: {{ .Values.image.pullPolicy }}
  48. command:
  49. - bin/tootctl
  50. - media
  51. - remove
  52. envFrom:
  53. - configMapRef:
  54. name: {{ include "mastodon.fullname" . }}-env
  55. - secretRef:
  56. name: {{ template "mastodon.secretName" . }}
  57. env:
  58. - name: "DB_PASS"
  59. valueFrom:
  60. secretKeyRef:
  61. name: {{ template "mastodon.postgresql.secretName" . }}
  62. key: password
  63. - name: "REDIS_PASSWORD"
  64. valueFrom:
  65. secretKeyRef:
  66. name: {{ template "mastodon.redis.secretName" . }}
  67. key: redis-password
  68. - name: "PORT"
  69. value: {{ .Values.mastodon.web.port | quote }}
  70. {{- if (not .Values.mastodon.s3.enabled) }}
  71. volumeMounts:
  72. - name: assets
  73. mountPath: /opt/mastodon/public/assets
  74. - name: system
  75. mountPath: /opt/mastodon/public/system
  76. {{- end }}
  77. {{- end }}