Skip to content

Commit 613bd67

Browse files
Jonathan S. Katzjkatz
Jonathan S. Katz
authored andcommitted
Add support for storing backups in Azure via Helm
This adds support both for a quickstart for storing backups in Azure Blob Storage via the Helm chart, as well as multi-repo support.
1 parent 0aff3be commit 613bd67

File tree

4 files changed

+50
-2
lines changed

4 files changed

+50
-2
lines changed

Diff for: helm/postgres/templates/_azure.tpl

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{/* Allow for Azure secret information to be stored in a Secret */}}
2+
{{- define "postgres.azure" }}
3+
[global]
4+
{{- if .azure }}
5+
{{- if .azure.account }}
6+
repo{{ add .index 1 }}-azure-account={{ .azure.account }}
7+
{{- end }}
8+
{{- if .azure.key }}
9+
repo{{ add .index 1 }}-azure-key={{ .azure.key }}
10+
{{- end }}
11+
{{- end }}
12+
{{ end }}

Diff for: helm/postgres/templates/pgbackrest-secret.yaml

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if or .Values.multiBackupRepos .Values.s3 .Values.gcs }}
1+
{{- if or .Values.multiBackupRepos .Values.s3 .Values.gcs .Values.azure }}
22
apiVersion: v1
33
kind: Secret
44
metadata:
@@ -17,6 +17,10 @@ data:
1717
{{ include "postgres.gcs" $args | b64enc }}
1818
gcs-key.json: |-
1919
{{ $repo.gcs.key | b64enc }}
20+
{{- else if $repo.azure }}
21+
{{- $args := dict "azure" $repo.azure "index" $index }}
22+
azure.conf: |-
23+
{{ include "postgres.azure" $args | b64enc }}
2024
{{- end }}
2125
{{- end }}
2226
{{- else if .Values.s3 }}
@@ -29,5 +33,9 @@ data:
2933
{{ include "postgres.gcs" $args | b64enc }}
3034
gcs-key.json: |-
3135
{{ .Values.gcs.key | b64enc }}
36+
{{- else if .Values.azure }}
37+
{{- $args := dict "azure" .Values.azure "index" 0 }}
38+
azure.conf: |-
39+
{{ include "postgres.azure" $args | b64enc }}
3240
{{- end }}
3341
{{- end }}

Diff for: helm/postgres/templates/postgres.yaml

+14-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ spec:
4646
name: {{ default .Release.Name .Values.name }}-pgbackrest-secret
4747
global:
4848
{{- range $index, $repo := .Values.multiBackupRepos }}
49-
{{- if or $repo.s3 $repo.gcs }}
49+
{{- if or $repo.s3 $repo.gcs $repo.azure }}
5050
repo{{ add $index 1 }}-path: /pgbackrest/{{ $.Release.Namespace }}/{{ default $.Release.Name $.Values.name }}/repo{{ add $index 1 }}
5151
{{- end }}
5252
{{- end }}
@@ -69,6 +69,9 @@ spec:
6969
{{- else if $repo.gcs }}
7070
gcs:
7171
bucket: {{ $repo.gcs.bucket | quote }}
72+
{{- else if $repo.azure }}
73+
azure:
74+
container: {{ $repo.azure.container | quote }}
7275
{{- end }}
7376
{{- end }}
7477
{{- else if .Values.s3 }}
@@ -96,6 +99,16 @@ spec:
9699
- name: repo1
97100
gcs:
98101
bucket: {{ .Values.gcs.bucket | quote }}
102+
{{- else if .Values.azure }}
103+
configuration:
104+
- secret:
105+
name: {{ default .Release.Name .Values.name }}-pgbackrest-secret
106+
global:
107+
repo1-path: /pgbackrest/{{ .Release.Namespace }}/{{ default .Release.Name .Values.name }}/repo1
108+
repos:
109+
- name: repo1
110+
azure:
111+
container: {{ .Values.azure.container | quote }}
99112
{{- else }}
100113
repos:
101114
- name: repo1

Diff for: helm/postgres/values.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,17 @@
200200
# key: |
201201
# {}
202202

203+
# azure allows for Azure Blob Storage to be used for backups. This allows
204+
# for a quick setup with Azure Blob Storage; if you need a more advanced setup,
205+
# use "pgBackRestConfig".
206+
# azure:
207+
# # account is the name of the Azure account to be used.
208+
# account: ""
209+
# # key is the Secret key used associated with the Azure acount.
210+
# key: ""
211+
# # container is the Azure container that the backups will be stored in.
212+
# container: ""
213+
203214
# multiBackupRepos allows for backing up to multiple repositories. This is
204215
# effectively uses the "quickstarts" for each of the backup types (volume, s3,
205216
# gcs, azure). You can have any permutation of these types. You can set up to 4.
@@ -224,6 +235,10 @@
224235
# bucket: ""
225236
# key: |
226237
# {}
238+
# - azure:
239+
# account: ""
240+
# key: ""
241+
# container: ""
227242

228243
# pgBackRestConfig allows for the configuration of every pgBackRest option
229244
# except for "image", which is set by "pgBackRest".

0 commit comments

Comments
 (0)