job-create-admin.yaml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.fullname" . }}
  60. env:
  61. - name: "DB_PASS"
  62. valueFrom:
  63. secretKeyRef:
  64. {{- if .Values.postgresql.enabled }}
  65. name: {{ .Release.Name }}-postgresql
  66. {{- else }}
  67. name: {{ template "mastodon.fullname" . }}
  68. {{- end }}
  69. key: postgresql-password
  70. - name: "REDIS_PASSWORD"
  71. valueFrom:
  72. secretKeyRef:
  73. name: {{ .Release.Name }}-redis
  74. key: redis-password
  75. - name: "PORT"
  76. value: {{ .Values.mastodon.web.port | quote }}
  77. {{- if (not .Values.mastodon.s3.enabled) }}
  78. volumeMounts:
  79. - name: assets
  80. mountPath: /opt/mastodon/public/assets
  81. - name: system
  82. mountPath: /opt/mastodon/public/system
  83. {{- end }}
  84. {{- end }}