1
0

job-create-admin.yaml 2.7 KB

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