|
| 1 | +{{- if .Values.migration.enabled }} |
| 2 | +apiVersion: batch/v1 |
| 3 | +kind: Job |
| 4 | +metadata: |
| 5 | + name: {{ default (printf "%s-migrate" (include "apex-dispatch-api.fullname" .)) .Values.migration.name }} |
| 6 | + labels: |
| 7 | + {{- include "apex-dispatch-api.labels" . | nindent 4 }} |
| 8 | + {{- with .Values.migration.labels }} |
| 9 | + {{- toYaml . | nindent 4 }} |
| 10 | + {{- end }} |
| 11 | + annotations: |
| 12 | + "helm.sh/hook": post-install,post-upgrade |
| 13 | + "helm.sh/hook-weight": "5" |
| 14 | + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded |
| 15 | + {{- with .Values.migration.annotations }} |
| 16 | + {{- toYaml . | nindent 4 }} |
| 17 | + {{- end }} |
| 18 | +spec: |
| 19 | + backoffLimit: {{ .Values.migration.backoffLimit }} |
| 20 | + {{- if gt (int .Values.migration.activeDeadlineSeconds) 0 }} |
| 21 | + activeDeadlineSeconds: {{ .Values.migration.activeDeadlineSeconds }} |
| 22 | + {{- end }} |
| 23 | + template: |
| 24 | + metadata: |
| 25 | + labels: |
| 26 | + {{- include "apex-dispatch-api.selectorLabels" . | nindent 8 }} |
| 27 | + spec: |
| 28 | + {{- $serviceAccountName := include "apex-dispatch-api.serviceAccountName" . }} |
| 29 | + restartPolicy: Never |
| 30 | + {{- with .Values.image.pullSecrets }} |
| 31 | + imagePullSecrets: |
| 32 | + {{- toYaml . | nindent 8 }} |
| 33 | + {{- end }} |
| 34 | + {{- if $serviceAccountName }} |
| 35 | + serviceAccountName: {{ $serviceAccountName }} |
| 36 | + {{- end }} |
| 37 | + containers: |
| 38 | + - name: migrate |
| 39 | + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" |
| 40 | + imagePullPolicy: {{ .Values.image.pullPolicy }} |
| 41 | + command: |
| 42 | + {{- toYaml .Values.migration.command | nindent 12 }} |
| 43 | + {{- with .Values.migration.args }} |
| 44 | + args: |
| 45 | + {{- toYaml . | nindent 12 }} |
| 46 | + {{- end }} |
| 47 | + env: |
| 48 | + - name: DATABASE_URL |
| 49 | + valueFrom: |
| 50 | + secretKeyRef: |
| 51 | + name: {{ .Values.secrets.name }} |
| 52 | + key: DATABASE_URL |
| 53 | + optional: {{ not .Values.secrets.create }} |
| 54 | + {{- with .Values.migration.extraEnv }} |
| 55 | + {{- toYaml . | nindent 12 }} |
| 56 | + {{- end }} |
| 57 | + {{- with .Values.resources }} |
| 58 | + resources: |
| 59 | + {{- toYaml . | nindent 12 }} |
| 60 | + {{- end }} |
| 61 | +{{- end }} |
0 commit comments