cronjob-media-remove.yaml 2.8 KB

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