TrueChartsClone/charts/stable/postgresql/templates/upgrade-backup-postgres-hoo...

57 lines
2.0 KiB
YAML

{{- if and ( .Values.enableUpgradeBackup ) ( .Values.ixChartContext ) -}}
{{- if .Values.ixChartContext.isUpgrade -}}
{{- $upgradeDict := .Values.ixChartContext.upgradeMetadata -}}
{{ $values := (. | mustDeepCopy) }}
---
apiVersion: batch/v1
kind: Job
metadata:
name: "pre-upgrade-hook2"
annotations:
"helm.sh/hook": pre-upgrade
"helm.sh/hook-weight": "1"
"helm.sh/hook-delete-policy": hook-succeeded
rollme: {{ randAlphaNum 5 | quote }}
spec:
template:
metadata:
name: "pre-upgrade-hook2"
spec:
restartPolicy: Never
containers:
- name: {{ .Chart.Name }}-postgres-backup
image: {{ printf "%v:%v" .Values.image.repository .Values.image.tag}}
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: BACKUP_NAME
value: {{- printf "postgres-backup-from-%s-to-%s-revision-%d" $upgradeDict.oldChartVersion $upgradeDict.newChartVersion (int64 $upgradeDict.preUpgradeRevision) -}}
- name: POSTGRES_USER
value: {{ .Values.postgresqlUsername | quote }}
- name: POSTGRES_DB
value: {{ .Values.postgresqlDatabase | quote }}
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ ( .Values.existingSecret | default ( include "common.names.fullname" . ) ) | quote }}
key: "postgresql-password"
command:
- "/bin/backup_entrypoint.sh"
volumeMounts:
- name: backup-script-configmap
mountPath: /bin/backup_entrypoint.sh
readOnly: true
subPath: entrypoint.sh
{{- with (include "common.controller.volumeMounts" . | trim) }}
{{ nindent 4 . }}
{{- end }}
volumes:
- name: backup-script-configmap
configMap:
defaultMode: 0700
name: "postgres-backup-hook-config-map"
{{- with (include "common.controller.volumes" . | trim) }}
{{- nindent 2 . }}
{{- end }}
{{- end -}}
{{- end -}}