backup-postgres-hook.yaml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. {{- if .Values.ixChartContext.isUpgrade -}}
  2. apiVersion: batch/v1
  3. kind: Job
  4. metadata:
  5. name: "pre-upgrade-hook2"
  6. annotations:
  7. "helm.sh/hook": pre-upgrade
  8. "helm.sh/hook-weight": "1"
  9. "helm.sh/hook-delete-policy": hook-succeeded
  10. rollme: {{ randAlphaNum 5 | quote }}
  11. spec:
  12. template:
  13. metadata:
  14. name: "pre-upgrade-hook2"
  15. spec:
  16. restartPolicy: Never
  17. serviceAccountName: "{{ template "nextcloud.serviceAccountName" . }}"
  18. containers:
  19. - name: {{ .Chart.Name }}-postgres-backup
  20. image: {{ template "postgres.imageName" . }}
  21. imagePullPolicy: {{ .Values.image.pullPolicy }}
  22. env:
  23. - name: POSTGRES_USER
  24. valueFrom:
  25. secretKeyRef:
  26. name: db-details
  27. key: db-user
  28. - name: POSTGRES_PASSWORD
  29. valueFrom:
  30. secretKeyRef:
  31. name: db-details
  32. key: db-password
  33. - name: BACKUP_NAME
  34. value: {{ template "postgres.backupName" . }}
  35. volumeMounts:
  36. - name: postgres-data
  37. mountPath: /var/lib/postgresql/data
  38. - name: postgres-backup
  39. mountPath: /postgres_backups
  40. - name: backup-script-configmap
  41. mountPath: /bin/backup_entrypoint.sh
  42. readOnly: true
  43. subPath: entrypoint.sh
  44. command:
  45. - "/bin/backup_entrypoint.sh"
  46. volumes:
  47. - name: postgres-data
  48. hostPath:
  49. path: {{ template "configuredPostgresHostPath" . }}
  50. - name: postgres-backup
  51. hostPath:
  52. path: {{ template "configuredBackupPostgresHostPath" . }}
  53. - name: backup-script-configmap
  54. configMap:
  55. defaultMode: 0700
  56. name: "postgres-backup-hook-config-map"
  57. {{- end -}}