Skip to content

Commit f70a1e9

Browse files
Modify GCP backup job and adding PVC configuration
Updated backup job configurations for GCP, including changes to restart policy and added persistent volume claim for backups.
1 parent e988790 commit f70a1e9

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

charts/devtron-backups/templates/backup-on-gcp.yaml

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ spec:
2828
schedule: "{{ .Values.global.schedule }}"
2929
jobTemplate:
3030
spec:
31-
backoffLimit: 0
32-
{{- if $.Values.global.extraConfig }}
33-
{{ toYaml $.Values.global.extraConfig | indent 6 }}
34-
{{- end }}
3531
template:
3632
{{- if or $.Values.postgres_backup.labels $.Values.postgres_backup.annotations }}
3733
metadata:
@@ -90,22 +86,27 @@ spec:
9086
- /bin/bash
9187
- -c
9288
{{- if $.Values.global.GCP.encryption.enabled }}
93-
- set -ex; echo $gcp_credentials > /postgres/gcp_credentials.json ; gcloud auth activate-service-account --key-file=/postgres/gcp_credentials.json ; date1=$(date +%Y%m%d-%H%M); gpg -c --batch --passphrase {{ .Values.global.GCP.encryption.passphrase }} /postgres/backup.tar; rm -rvf /postgres/backup.tar; mv /postgres/backup.tar.gpg /postgres/backup-$date1.tar.gpg; gsutil cp /postgres/backup-$date1.tar.gpg gs://$GCS_BUCKET/postgres/;
89+
- set -ex; echo $gcp_credentials > /postgres/gcp_credentials.json ; gcloud auth activate-service-account --key-file=/postgres/gcp_credentials.json ; date1=$(date +%Y%m%d-%H%M); gpg -c --batch --passphrase {{ .Values.global.GCP.encryption.passphrase }} /postgres/backup.tar; rm -rvf /postgres/backup.tar; mv /postgres/backup.tar.gpg /postgres/backup-$date1.tar.gpg; gsutil cp /postgres/backup-$date1.tar.gpg gs://$GCS_BUCKET/postgres/; rm -rvf /postgres/backup-$date1.tar.gpg;
9490
{{- else}}
95-
- set -ex; echo $gcp_credentials > /postgres/gcp_credentials.json ; gcloud auth activate-service-account --key-file=/postgres/gcp_credentials.json ; date1=$(date +%Y%m%d-%H%M); mv /postgres/backup.tar /postgres/backup-$date1.tar; gsutil cp /postgres/backup-$date1.tar gs://$GCS_BUCKET/postgres/;
91+
- set -ex; echo $gcp_credentials > /postgres/gcp_credentials.json ; gcloud auth activate-service-account --key-file=/postgres/gcp_credentials.json ; date1=$(date +%Y%m%d-%H%M); mv /postgres/backup.tar /postgres/backup-$date1.tar; gsutil cp /postgres/backup-$date1.tar gs://$GCS_BUCKET/postgres/; rm -rvf /postgres/backup-$date1.tar.gpg;
9692
{{- end }}
9793
volumes:
98-
- name: psql-volume
99-
emptyDir: {}
100-
{{- if $.Values.global.nodeSelector }}
94+
- name: psql-volume
95+
persistentVolumeClaim:
96+
{{- if and .Values.global.GCP.PERSISTENCE.enabled .Values.global.GCP.PERSISTENCE.existingClaim }}
97+
claimName: {{ .Values.global.GCP.PERSISTENCE.existingClaim }}
98+
{{- else }}
99+
claimName: devtron-backup-pvc
100+
{{- end }}
101+
{{- if $.Values.global.nodeSelector }}
101102
nodeselector:
102103
{{ toYaml .Values.global.nodeSelector | indent 12 }}
103104
{{- end }}
104105
{{- if $.Values.global.tolerations }}
105106
tolerations:
106107
{{ toYaml .Values.global.tolerations | indent 12 }}
107108
{{- end }}
108-
restartPolicy: Never
109+
restartPolicy: OnFailure
109110
serviceAccountName: {{ .Values.postgres_backup.serviceAccountName | default "default" }}
110111
{{- end }}
111112
---
@@ -124,10 +125,6 @@ spec:
124125
schedule: "{{ .Values.global.schedule }}"
125126
jobTemplate:
126127
spec:
127-
backoffLimit: 0
128-
{{- if $.Values.global.extraConfig }}
129-
{{ toYaml $.Values.global.extraConfig | indent 6 }}
130-
{{- end }}
131128
template:
132129
{{- if or $.Values.postgres_backup.labels $.Values.postgres_backup.annotations }}
133130
metadata:
@@ -196,7 +193,25 @@ spec:
196193
tolerations:
197194
{{ toYaml .Values.global.tolerations | indent 12 }}
198195
{{- end }}
199-
restartPolicy: Never
196+
restartPolicy: OnFailure
200197
serviceAccountName: {{ .Values.argocd_backup.serviceAccountName }}
201198
{{- end }}
202-
{{- end }}
199+
{{- end }}
200+
201+
{{- if and (.Values.global.GCP.enabled) (.Values.global.GCP.PERSISTENCE.enabled) (not .Values.global.GCP.PERSISTENCE.existingClaim) }}
202+
---
203+
apiVersion: v1
204+
kind: PersistentVolumeClaim
205+
metadata:
206+
name: devtron-backup-pvc
207+
namespace: devtroncd
208+
spec:
209+
{{- if .Values.global.GCP.PERSISTENCE.storageClass }}
210+
storageClassName: {{ .Values.global.GCP.PERSISTENCE.storageClass }}
211+
{{- end }}
212+
accessModes:
213+
- ReadWriteOnce
214+
resources:
215+
requests:
216+
storage: {{ .Values.global.GCP.PERSISTENCE.size }}
217+
{{- end }}

0 commit comments

Comments
 (0)