Skip to content

Commit 7ba9af5

Browse files
committed
Add s3 backups to pgdb01 with prefer-standby as target
1 parent 64d426c commit 7ba9af5

4 files changed

Lines changed: 91 additions & 16 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{{- if .Values.db.backups.s3.enabled }}
2+
apiVersion: batch/v1
3+
kind: CronJob
4+
metadata:
5+
name: {{ .Values.db.name }}-s3-backup-compressor
6+
spec:
7+
schedule: "0 12 * * *"
8+
jobTemplate:
9+
spec:
10+
template:
11+
spec:
12+
restartPolicy: OnFailure
13+
containers:
14+
- name: compressor
15+
image: hub.k8s.ucar.edu/khrpcek/backup-compressor:kmh
16+
command: ["/multi_compress.sh"]
17+
imagePullPolicy: Always
18+
env:
19+
- name: BASEDIR
20+
value: "{{ .Values.db.backups.s3.destinationPath }}/{{ .Values.db.name }}/base/"
21+
- name: AWS_ENDPOINT_URL
22+
value: "{{ .Values.db.backups.s3.endpointURL }}"
23+
- name: AWS_ACCESS_KEY_ID
24+
valueFrom:
25+
secretKeyRef:
26+
name: {{ .Values.db.backups.s3.secretName }}
27+
key: access_key
28+
- name: AWS_SECRET_ACCESS_KEY
29+
valueFrom:
30+
secretKeyRef:
31+
name: {{ .Values.db.backups.s3.secretName }}
32+
key: secret_key
33+
resources:
34+
requests:
35+
memory: 12Gi
36+
cpu: 30
37+
limits:
38+
memory: 16Gi
39+
cpu: 32
40+
{{- end }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{- if .Values.db.backups.s3.enabled }}
2+
apiVersion: barmancloud.cnpg.io/v1
3+
kind: ObjectStore
4+
metadata:
5+
name: boreas
6+
spec:
7+
retentionPolicy: "14d"
8+
configuration:
9+
destinationPath: {{ .Values.db.backups.s3.destinationPath }}
10+
endpointURL: {{ .Values.db.backups.s3.endpointURL }}
11+
s3Credentials:
12+
accessKeyId:
13+
name: {{ .Values.db.backups.s3.secretName }}
14+
key: access_key
15+
secretAccessKey:
16+
name: {{ .Values.db.backups.s3.secretName }}
17+
key: secret_key
18+
wal:
19+
compression: bzip2
20+
{{- end }}

pgdb01-cirrus/templates/postgres_cluster.yaml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,15 @@ spec:
2121
volumeSnapshot:
2222
className: {{ .Values.db.backups.volumeSnapshot.snapshotClassName }}
2323
{{- end }}
24-
{{- if .Values.db.backups.s3.enabled }}
25-
barmanObjectStore:
26-
wal:
27-
compression: bzip2
28-
data:
29-
compression: bzip2
30-
destinationPath: {{ .Values.db.backups.s3.destinationPath }}
31-
endpointURL: {{ .Values.db.backups.s3.endpointURL }}
32-
s3Credentials:
33-
accessKeyId:
34-
name: {{ .Values.db.backups.s3.secretName }}
35-
key: access_key
36-
secretAccessKey:
37-
name: {{ .Values.db.backups.s3.secretName }}
38-
key: secret_key
39-
{{- end }}
24+
{{- end }}
25+
26+
{{- if .Values.db.backups.s3.enabled }}
27+
plugins:
28+
- enabled: true
29+
isWALArchiver: false
30+
name: barman-cloud.cloudnative-pg.io
31+
parameters:
32+
barmanObjectName: boreas
4033
{{- end }}
4134

4235
# Add TLS certificates for encrypted communication
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{- if .Values.db.backups.s3.enabled }}
2+
apiVersion: postgresql.cnpg.io/v1
3+
kind: ScheduledBackup
4+
metadata:
5+
name: {{ .Values.db.name }}-s3-backup
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
app: {{ .Values.db.name }}
9+
spec:
10+
# Schedule: Roughly midnight local time
11+
schedule: "0 0 5 */3 * *"
12+
13+
backupOwnerReference: self
14+
15+
cluster:
16+
name: {{ .Values.db.name }}
17+
18+
target: prefer-standby
19+
method: plugin
20+
pluginConfiguration:
21+
name: barman-cloud.cloudnative-pg.io
22+
{{- end }}

0 commit comments

Comments
 (0)