backup-postgres-hook.yaml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. {{- if .Values.ixChartContext.isUpgrade -}}
  2. {{ $values := . }}
  3. {{ $_ := set $values "nameSuffix" "postgres" }}
  4. apiVersion: batch/v1
  5. kind: Job
  6. metadata:
  7. name: "pre-upgrade-hook2"
  8. annotations:
  9. "helm.sh/hook": pre-upgrade
  10. "helm.sh/hook-weight": "1"
  11. "helm.sh/hook-delete-policy": hook-succeeded
  12. rollme: {{ randAlphaNum 5 | quote }}
  13. spec:
  14. template:
  15. metadata:
  16. name: "pre-upgrade-hook2"
  17. spec:
  18. restartPolicy: Never
  19. serviceAccountName: "{{ template "common.names.serviceAccountName" . }}"
  20. containers:
  21. - name: {{ .Chart.Name }}-postgres-backup
  22. image: {{ template "postgres.imageName" . }}
  23. imagePullPolicy: {{ .Values.image.pullPolicy }}
  24. env: {{ include "postgres.envVariableConfiguration" $values | nindent 10 }}
  25. - name: BACKUP_NAME
  26. value: {{ template "postgres.backupName" . }}
  27. volumeMounts:
  28. - name: postgres-data
  29. mountPath: /var/lib/postgresql/data
  30. - name: postgres-backup
  31. mountPath: /postgres_backups
  32. - name: backup-script-configmap
  33. mountPath: /bin/backup_entrypoint.sh
  34. readOnly: true
  35. subPath: entrypoint.sh
  36. command:
  37. - "/bin/backup_entrypoint.sh"
  38. volumes: {{ include "postgres.volumeConfiguration" $values | nindent 8 }}
  39. - name: backup-script-configmap
  40. configMap:
  41. defaultMode: 0700
  42. name: "postgres-backup-hook-config-map"
  43. {{- end -}}