Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cnpg): use superuser secret for backups #32

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions charts/cnpg-cluster/templates/backup-cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,20 @@ spec:
- name: AWS_ENDPOINT_URL
value: {{ .Values.backup.barmanObjectStore.endpointURL }}
- name: DESTINATION_PATH
value: {{ trimSuffix "/" .Values.backup.barmanObjectStore.destinationPath }}/dumps
envFrom:
- secretRef:
name: {{ .Values.backup.sqlDumpPgSecret }}
value: {{ trimSuffix "/" .Values.backup.barmanObjectStore.destinationPath }}/{{ include "cnpg-cluster.fullname" . }}/dumps
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: {{ include "cnpg-cluster.fullname" $ }}-superuser
key: password
- name: PGUSER
valueFrom:
secretKeyRef:
name: {{ include "cnpg-cluster.fullname" $ }}-superuser
key: username
- name: PGDATABASE
value: {{ .Values.dbName }}
- name: PGHOST
value: {{ include "cnpg-cluster.fullname" $ }}-r

{{- end}}
19 changes: 15 additions & 4 deletions charts/cnpg-cluster/tests/__snapshot__/cnpg-cluster_test.yaml.snap
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,21 @@ cluster with enabled backup and recovery:
- name: AWS_ENDPOINT_URL
value: http://minio:9000
- name: DESTINATION_PATH
value: s3://backups/dumps
envFrom:
- secretRef:
name: pg-user-app
value: s3://backups/RELEASE-NAME-cnpg-cluster/dumps
- name: PGPASSWORD
valueFrom:
secretKeyRef:
key: password
name: RELEASE-NAME-cnpg-cluster-superuser
- name: PGUSER
valueFrom:
secretKeyRef:
key: username
name: RELEASE-NAME-cnpg-cluster-superuser
- name: PGDATABASE
value: app
- name: PGHOST
value: RELEASE-NAME-cnpg-cluster-r
image: ghcr.io/socialgouv/docker/s3-client:1
imagePullPolicy: IfNotPresent
name: s3-client
Expand Down
3 changes: 0 additions & 3 deletions charts/cnpg-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ backup:
# -- Schedule the SQL dump backups, for instance every Sunday
sqlDumpSchedule: "0 0 * * 0"

# -- Secret where pg_dump will look for DB credentials
sqlDumpPgSecret:

# -- RetentionPolicy is the retention policy to be used for backups and WALs (i.e. '60d').
# The retention policy is expressed in the form of XXu where XX is a positive integer and
# u is in [dwm] - days, weeks, months.
Expand Down