backup-postgres-hook.yaml 1.7 KB

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