Skip to content

Commit

Permalink
Merge pull request #252 from devtron-labs/devtron-backup-new
Browse files Browse the repository at this point in the history
feat: update chart
  • Loading branch information
Neha130 authored Nov 12, 2024
2 parents 6448e4c + b9881a5 commit a5956dd
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 54 deletions.
2 changes: 1 addition & 1 deletion charts/devtron-backups/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v2
appVersion: "2.0"
description: A Helm chart for Devtron Backups
name: devtron-backups
version: 0.2.2
version: 0.2.3
36 changes: 22 additions & 14 deletions charts/devtron-backups/templates/backup-on-azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
- name: postgres-app-backup-cronjob
image: {{ .Values.postgres_backup.postgresImage | default "postgres:12" }}
volumeMounts:
- mountPath: /tmp
- mountPath: /postgres
name: psql-volume
env:
- name: PGPASSWORD
Expand All @@ -45,12 +45,14 @@ spec:
args:
- /bin/bash
- -c
- pg_dumpall -h {{ .Values.postgres_backup.host | default "postgresql-postgresql.devtroncd" }} --exclude-database=clairv4 -p 5432 -U postgres --no-privileges > /tmp/backup.tar;
- set -ex ; pg_dumpall -h {{ .Values.postgres_backup.host | default "postgresql-postgresql.devtroncd" }} --exclude-database=clairv4 -p 5432 -U postgres --no-privileges > /postgres/backup.tar; echo $? ; du -sh /postgres/backup.tar
resources:
{{ toYaml .Values.postgres_backup.resources | indent 13 }}
containers:
- name: az-cli-for-upload
image: {{ .Values.global.AZURE.image | default "quay.io/devtron/k8s-utils:az-cli-ubuntu" }}
volumeMounts:
- mountPath: /tmp
- mountPath: /postgres
name: psql-volume
env:
- name: AZURE_BLOB_ACCOUNT_NAME
Expand All @@ -74,13 +76,15 @@ spec:
name: devtron-azure-backup-secret
key: AZURE_BLOB_CONTAINER_FOR_ARGOCD
imagePullPolicy: Always
resources:
{{ toYaml .Values.postgres_backup.resources | indent 13 }}
args:
- /bin/bash
- -c
{{- if $.Values.global.AZURE.encryption.enabled }}
- date1=$(date +%Y%m%d-%H%M); gpg -c --batch --passphrase {{ .Values.global.AZURE.encryption.passphrase }} /tmp/backup.tar; rm -rvf /tmp/backup.tar; mv /tmp/backup.tar.gpg /tmp/backup-$date1.tar.gpg; az storage blob upload --account-name $AZURE_BLOB_ACCOUNT_NAME --container-name $AZURE_BLOB_CONTAINER_FOR_POSTGRES --file /tmp/backup-$date1.tar.gpg --account-key $AZURE_ACCOUNT_KEY;
{{- if $.Values.global.AZURE.encryption.enabled }}
- set -ex; date1=$(date +%Y%m%d-%H%M); gpg -c --batch --passphrase {{ .Values.global.AZURE.encryption.passphrase }} /postgres/backup.tar; rm -rvf /postgres/backup.tar; mv /postgres/backup.tar.gpg /postgres/backup-$date1.tar.gpg; az storage blob upload --account-name $AZURE_BLOB_ACCOUNT_NAME --container-name $AZURE_BLOB_CONTAINER_FOR_POSTGRES --file /postgres/backup-$date1.tar.gpg --account-key $AZURE_ACCOUNT_KEY;
{{- else }}
- date1=$(date +%Y%m%d-%H%M); mv /tmp/backup.tar /tmp/backup-$date1.tar; az storage blob upload --account-name $AZURE_BLOB_ACCOUNT_NAME --container-name $AZURE_BLOB_CONTAINER_FOR_POSTGRES --file /tmp/backup-$date1.tar --account-key $AZURE_ACCOUNT_KEY;
- set -ex; date1=$(date +%Y%m%d-%H%M); mv /postgres/backup.tar /postgres/backup-$date1.tar; az storage blob upload --account-name $AZURE_BLOB_ACCOUNT_NAME --container-name $AZURE_BLOB_CONTAINER_FOR_POSTGRES --file /postgres/backup-$date1.tar --account-key $AZURE_ACCOUNT_KEY;
{{- end }}
volumes:
- name: psql-volume
Expand All @@ -96,8 +100,8 @@ apiVersion: batch/v1beta1
{{ end -}}
kind: CronJob
metadata:
name: argocd-app-backup-cronjob
namespace: devtroncd
name: argocd-app-backup-cronjob
namespace: devtroncd
spec:
schedule: {{ .Values.global.schedule }}
jobTemplate:
Expand All @@ -108,19 +112,21 @@ spec:
- name: argocd-app-backup-job
image: {{ .Values.argocd_backup.argocdImage | default "quay.io/argoproj/argocd:v2.4.0" }}
volumeMounts:
- mountPath: /cache
- mountPath: /argocd
name: argocd-volume
env:
imagePullPolicy: Always
args:
- /bin/bash
- -c
- {{ .Values.argocd_backup.args | default "argocd admin export -n devtroncd > /cache/backup.yaml" }}
- {{ .Values.argocd_backup.args | default "argocd admin export -n devtroncd > /argocd/backup.yaml" }}
resources:
{{ toYaml .Values.argocd_backup.resources | indent 13 }}
containers:
- name: az-cli-for-upload
image: {{ .Values.global.AZURE.image | default "quay.io/devtron/k8s-utils:az-cli-ubuntu" }}
volumeMounts:
- mountPath: /cache
- mountPath: /argocd
name: argocd-volume
env:
- name: AZURE_BLOB_ACCOUNT_NAME
Expand All @@ -144,18 +150,20 @@ spec:
name: devtron-azure-backup-secret
key: AZURE_BLOB_CONTAINER_FOR_ARGOCD
imagePullPolicy: Always
resources:
{{ toYaml .Values.argocd_backup.resources | indent 13 }}
args:
- /bin/bash
- -c
{{- if $.Values.global.AZURE.encryption.enabled }}
- date1=$(date +%Y%m%d-%H%M); gpg -c --batch --passphrase {{ .Values.global.AZURE.encryption.passphrase }} /cache/backup.yaml ;rm -rvf /cache/backup.yaml ;mv /cache/backup.yaml.gpg /cache/backup-$date1.yaml.gpg; az storage blob upload --account-name $AZURE_BLOB_ACCOUNT_NAME --container-name $AZURE_BLOB_CONTAINER_FOR_ARGOCD --file /cache/backup-$date1.yaml.gpg --account-key $AZURE_ACCOUNT_KEY;
- set -ex; date1=$(date +%Y%m%d-%H%M); gpg -c --batch --passphrase {{ .Values.global.AZURE.encryption.passphrase }} /argocd/backup.yaml ;rm -rvf /argocd/backup.yaml ;mv /argocd/backup.yaml.gpg /argocd/backup-$date1.yaml.gpg; az storage blob upload --account-name $AZURE_BLOB_ACCOUNT_NAME --container-name $AZURE_BLOB_CONTAINER_FOR_ARGOCD --file /argocd/backup-$date1.yaml.gpg --account-key $AZURE_ACCOUNT_KEY;
{{- else }}
- date1=$(date +%Y%m%d-%H%M); mv /cache/backup.yaml /cache/backup-$date1.yaml; az storage blob upload --account-name $AZURE_BLOB_ACCOUNT_NAME --container-name $AZURE_BLOB_CONTAINER_FOR_ARGOCD --file /cache/backup-$date1.yaml --account-key $AZURE_ACCOUNT_KEY;
- set -ex; date1=$(date +%Y%m%d-%H%M); mv /argocd/backup.yaml /argocd/backup-$date1.yaml; az storage blob upload --account-name $AZURE_BLOB_ACCOUNT_NAME --container-name $AZURE_BLOB_CONTAINER_FOR_ARGOCD --file /argocd/backup-$date1.yaml --account-key $AZURE_ACCOUNT_KEY;
{{- end }}
volumes:
- name: argocd-volume
emptyDir: {}
restartPolicy: OnFailure
serviceAccountName: {{ .Values.argocd_backup.serviceAccountName }}
{{- end }}
{{- end }}
{{- end }}
28 changes: 18 additions & 10 deletions charts/devtron-backups/templates/backup-on-gcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
- name: postgres-app-backup-cronjob
image: {{ .Values.postgres_backup.postgresImage | default "postgres:12" }}
volumeMounts:
- mountPath: /tmp
- mountPath: /postgres
name: psql-volume
env:
- name: PGPASSWORD
Expand All @@ -45,12 +45,14 @@ spec:
args:
- /bin/bash
- -c
- pg_dumpall -h {{ .Values.postgres_backup.host | default "postgresql-postgresql.devtroncd" }} --exclude-database=clairv4 -p 5432 -U postgres --no-privileges > /tmp/backup.tar;
- set -ex; pg_dumpall -h {{ .Values.postgres_backup.host | default "postgresql-postgresql.devtroncd" }} --exclude-database=clairv4 -p 5432 -U postgres --no-privileges > /postgres/backup.tar; echo $? ; du -sh /postgres/backup.tar
resources:
{{ toYaml .Values.postgres_backup.resources | indent 13 }}
containers:
- name: gcloud-cli-for-cloud-storage-upload
image: {{ .Values.global.GCP.image | default "google/cloud-sdk:alpine" }}
volumeMounts:
- mountPath: /tmp
- mountPath: /postgres
name: psql-volume
env:
- name: GCS_BUCKET
Expand All @@ -66,13 +68,15 @@ spec:
key: GOOGLE_APPLICATION_CREDENTIALS
{{- end }}
imagePullPolicy: Always
resources:
{{ toYaml .Values.postgres_backup.resources | indent 13 }}
args:
- /bin/bash
- -c
{{- if $.Values.global.GCP.encryption.enabled }}
- echo $gcp_credentials > /tmp/gcp_credentials.json ; gcloud auth activate-service-account --key-file=/tmp/gcp_credentials.json ; date1=$(date +%Y%m%d-%H%M); gpg -c --batch --passphrase {{ .Values.global.GCP.encryption.passphrase }} /tmp/backup.tar; rm -rvf /tmp/backup.tar; mv /tmp/backup.tar.gpg /tmp/backup-$date1.tar.gpg; gsutil cp /tmp/backup-$date1.tar.gpg gs://$GCS_BUCKET/postgres/;
- 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/;
{{- else}}
- echo $gcp_credentials > /tmp/gcp_credentials.json ; gcloud auth activate-service-account --key-file=/tmp/gcp_credentials.json ; date1=$(date +%Y%m%d-%H%M); mv /tmp/backup.tar /tmp/backup-$date1.tar; gsutil cp /tmp/backup-$date1.tar gs://$GCS_BUCKET/postgres/;
- 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/;
{{- end }}
volumes:
- name: psql-volume
Expand Down Expand Up @@ -101,19 +105,21 @@ spec:
- name: argocd-app-backup-job
image: {{ .Values.argocd_backup.argocdImage | default "quay.io/argoproj/argocd:v2.4.0" }}
volumeMounts:
- mountPath: /cache
- mountPath: /argocd
name: argocd-volume
env:
imagePullPolicy: Always
args:
- /bin/bash
- -c
- {{ .Values.argocd_backup.args | default "argocd admin export -n devtroncd > /cache/backup.yaml" }}
- {{ .Values.argocd_backup.args | default "argocd admin export -n devtroncd > /argocd/backup.yaml" }}
resources:
{{ toYaml .Values.argocd_backup.resources | indent 13 }}
containers:
- name: gcloud-cli-for-cloud-storage-upload
image: {{ .Values.global.GCP.image | default "google/cloud-sdk:alpine" }}
volumeMounts:
- mountPath: /cache
- mountPath: /argocd
name: argocd-volume
env:
- name: GCS_BUCKET
Expand All @@ -129,13 +135,15 @@ spec:
key: GOOGLE_APPLICATION_CREDENTIALS
{{- end }}
imagePullPolicy: Always
resources:
{{ toYaml .Values.argocd_backup.resources | indent 13 }}
args:
- /bin/bash
- -c
{{- if $.Values.global.GCP.encryption.enabled }}
- echo $gcp_credentials > /tmp/gcp_credentials.json ; gcloud auth activate-service-account --key-file=/tmp/gcp_credentials.json ; date1=$(date +%Y%m%d-%H%M); gpg -c --batch --passphrase {{ .Values.global.GCP.encryption.passphrase }} /cache/backup.yaml; rm -rvf /cache/backup.yaml; mv /cache/backup.yaml.gpg /cache/backup-$date1.yaml.gpg; gsutil cp /cache/backup-$date1.yaml.gpg gs://$GCS_BUCKET/argocd/;
- set -ex; echo $gcp_credentials > /argocd/gcp_credentials.json ; gcloud auth activate-service-account --key-file=/argocd/gcp_credentials.json ; date1=$(date +%Y%m%d-%H%M); gpg -c --batch --passphrase {{ .Values.global.GCP.encryption.passphrase }} /argocd/backup.yaml; rm -rvf /argocd/backup.yaml; mv /argocd/backup.yaml.gpg /argocd/backup-$date1.yaml.gpg; gsutil cp /argocd/backup-$date1.yaml.gpg gs://$GCS_BUCKET/argocd/;
{{- else}}
- echo $gcp_credentials > /tmp/gcp_credentials.json ; gcloud auth activate-service-account --key-file=/tmp/gcp_credentials.json ; date1=$(date +%Y%m%d-%H%M); mv /cache/backup.yaml /cache/backup-$date1.yaml; gsutil cp /cache/backup-$date1.yaml gs://$GCS_BUCKET/argocd/;
- set -ex; echo $gcp_credentials > /argocd/gcp_credentials.json ; gcloud auth activate-service-account --key-file=/argocd/gcp_credentials.json ; date1=$(date +%Y%m%d-%H%M); mv /argocd/backup.yaml /argocd/backup-$date1.yaml; gsutil cp /argocd/backup-$date1.yaml gs://$GCS_BUCKET/argocd/;
{{- end }}
volumes:
- name: argocd-volume
Expand Down
13 changes: 8 additions & 5 deletions charts/devtron-backups/templates/backup-on-pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

{{- if .Values.global.PERSISTENCE.enabled }}
{{- if .Values.postgres_backup.enabled }}
{{- if semverCompare ">=1.21-0" .Capabilities.KubeVersion.GitVersion }}
Expand Down Expand Up @@ -33,10 +32,12 @@ spec:
- /bin/bash
- -c
{{- if $.Values.global.PERSISTENCE.encryption.enabled }}
- mkdir -p /postgres/ ; date1=$(date +%Y%m%d-%H%M); pg_dumpall -h postgresql-postgresql.devtroncd -p 5432 -U postgres --no-privileges > /postgres/backup-$date1.tar ; gpg -c --batch --passphrase {{ .Values.global.PERSISTENCE.encryption.passphrase }} /postgres/backup-$date1.tar ; rm -rvf /postgres/backup-$date1.tar;
- set -ex; mkdir -p /postgres/ ; date1=$(date +%Y%m%d-%H%M); pg_dumpall -h postgresql-postgresql.devtroncd -p 5432 -U postgres --no-privileges > /postgres/backup-$date1.tar ; gpg -c --batch --passphrase {{ .Values.global.PERSISTENCE.encryption.passphrase }} /postgres/backup-$date1.tar ; rm -rvf /postgres/backup-$date1.tar;
{{- else }}
- mkdir -p /postgres/ ; date1=$(date +%Y%m%d-%H%M); pg_dumpall -h {{ .Values.postgres_backup.host | default "postgresql-postgresql.devtroncd" }} --exclude-database=clairv4 -p 5432 -U postgres --no-privileges > /postgres/backup-$date1.tar ;
- set -ex; mkdir -p /postgres/ ; date1=$(date +%Y%m%d-%H%M); pg_dumpall -h {{ .Values.postgres_backup.host | default "postgresql-postgresql.devtroncd" }} --exclude-database=clairv4 -p 5432 -U postgres --no-privileges > /postgres/backup-$date1.tar ;
{{- end }}
resources:
{{ toYaml .Values.postgres_backup.resources | indent 13 }}
volumes:
- name: psql-volume
persistentVolumeClaim:
Expand Down Expand Up @@ -93,10 +94,12 @@ spec:
- /bin/bash
- -c
{{- if $.Values.global.PERSISTENCE.encryption.enabled }}
- mkdir -p /argo-cd/ ; date1=$(date +%Y%m%d-%H%M); {{ .Values.argocd_backup.args | default "argocd admin export -n devtroncd" }} > /argo-cd/backup-$date1.tar ; gpg -c --batch --passphrase {{ .Values.global.PERSISTENCE.encryption.passphrase }} /argo-cd/backup-$date1.tar; rm -rvf /argo-cd/backup-$date1.tar;
- set -ex; mkdir -p /argo-cd/ ; date1=$(date +%Y%m%d-%H%M); {{ .Values.argocd_backup.args | default "argocd admin export -n devtroncd" }} > /argo-cd/backup-$date1.tar ; gpg -c --batch --passphrase {{ .Values.global.PERSISTENCE.encryption.passphrase }} /argo-cd/backup-$date1.tar; rm -rvf /argo-cd/backup-$date1.tar;
{{- else }}
- mkdir -p /argo-cd/ ; date1=$(date +%Y%m%d-%H%M); {{ .Values.argocd_backup.args | default "argocd admin export -n devtroncd" }} > /argo-cd/backup-$date1.tar ;
- set -ex; mkdir -p /argo-cd/ ; date1=$(date +%Y%m%d-%H%M); {{ .Values.argocd_backup.args | default "argocd admin export -n devtroncd" }} > /argo-cd/backup-$date1.tar ;
{{- end }}
resources:
{{ toYaml .Values.argocd_backup.resources | indent 13 }}
volumes:
- name: argocd-volume
persistentVolumeClaim:
Expand Down
Loading

0 comments on commit a5956dd

Please sign in to comment.