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