job-create-admin.yaml 2.9 KB

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