From 44245a143f0a07c8bcedc456f2b012a59be10d6a Mon Sep 17 00:00:00 2001 From: Moritz Jorg Date: Tue, 18 Mar 2025 13:21:01 +0100 Subject: [PATCH] fix(cnpg): Add scheduled backup to atlantis chart To work update the bucket-name and add the `nutanix-s3` secret to the namespace. --- charts/atlantis/templates/cluster.yaml | 17 ++++++++++++++++- charts/atlantis/templates/schedule.yaml | 11 +++++++++++ charts/atlantis/values.yaml | 6 ++++-- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 charts/atlantis/templates/schedule.yaml diff --git a/charts/atlantis/templates/cluster.yaml b/charts/atlantis/templates/cluster.yaml index 57c19e7b..2659d0db 100644 --- a/charts/atlantis/templates/cluster.yaml +++ b/charts/atlantis/templates/cluster.yaml @@ -17,8 +17,23 @@ spec: # - supervised: requires manual supervision to perform # the switchover of the primary primaryUpdateStrategy: unsupervised + {{- if .Values.cluster.backup.enabled }} backup: - retentionPolicy: {{ .Values.cluster.backupRetention | default "60d" }} + barmanObjectStore: + destinationPath: {{ .Values.cluster.destinationPath | default ""}} + serverName: {{ include "Atlantis.fullname" . }}-db + endpointURL: http://10.255.241.30:30080 + s3Credentials: + accessKeyId: + key: access_key + name: cnpg-s3 + secretAccessKey: + key: access_secret + name: cnpg-s3 + wal: + compression: snappy + retentionPolicy: {{ .Values.cluster.backup.backupRetention | default "60d" }} + {{- end}} storage: size: {{ .Values.cluster.size | default "5Gi" }} {{- with .Values.cluster.bootstrap }} diff --git a/charts/atlantis/templates/schedule.yaml b/charts/atlantis/templates/schedule.yaml new file mode 100644 index 00000000..6fb96852 --- /dev/null +++ b/charts/atlantis/templates/schedule.yaml @@ -0,0 +1,11 @@ +{{- if and .Values.cluster.backup.enabled .Values.cluster.enabled -}} +apiVersion: postgresql.cnpg.io/v1 +kind: ScheduledBackup +metadata: + name: {{ include "Atlantis.fullname" . }}-db +spec: + schedule: "0 0 1 * * *" + backupOwnerReference: self + cluster: + name: '{{ include "Atlantis.fullname" . }}-db' +{{- end }} diff --git a/charts/atlantis/values.yaml b/charts/atlantis/values.yaml index 67d1db7e..8cd07493 100644 --- a/charts/atlantis/values.yaml +++ b/charts/atlantis/values.yaml @@ -76,8 +76,10 @@ persistence: cluster: enabled: true instances: 1 - backupEnabled: true - backupRetention: 60d + destinationPath: "s3://cnpg/prod-atlantis-db" + backup: + enabled: false + backupRetention: 60d size: 5Gi bootstrap: enabled: true