django-helm-chart/templates/migrate-job.yaml

67 lines
2.4 KiB
YAML

{{- if .Values.migrationJob.enabled -}}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "django.fullname" . }}-migrate
labels:
{{- include "django.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": post-install,pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
"helm.sh/hook-weight": "0"
checksum/secret: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }}
checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
tag: "{{ .Values.image.tag }}"
spec:
activeDeadlineSeconds: {{ default 900 .Values.migrationJob.activeDeadlineSeconds }}
template:
metadata:
labels:
app.kubernetes.io/component: migrate-job
{{- include "django.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "django.serviceAccountName" . }}
restartPolicy: Never
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: migrate-job
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.migrationJob.resources }}
resources: {{ toYaml .Values.migrationJob.resources | nindent 12 }}
{{- end }}
command: {{ .Values.migrationJob.command | default (list "./manage.py" "migrate") | toJson }}
env:
{{- if .Values.postgresql.enabled }}
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ default (include "django.postgresql.fullname" .) .Values.postgresql.auth.existingSecret }}
key: postgres-password
{{- end }}
envFrom:
- secretRef:
name: {{ include "django.fullname" . }}
{{- if .Values.existingSecret }}
- secretRef:
name: {{ .Values.existingSecret }}
{{- end }}
- configMapRef:
name: {{ include "django.fullname" . }}
{{- with .Values.extraVolumeMounts }}
volumeMounts:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.extraVolumes }}
volumes:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end }}