Skip to content

Commit b24dec1

Browse files
committed
feat(recovery): use plugin to recover cluster when plugin is enabled
Signed-off-by: Philipp Hamann <[email protected]>
1 parent 7782a65 commit b24dec1

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

charts/cluster/templates/_bootstrap.tpl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,25 +86,35 @@ externalClusters:
8686
recoveryTarget:
8787
targetTime: {{ . }}
8888
{{- end }}
89-
{{ with .Values.recovery.database }}
89+
{{- with .Values.recovery.database }}
9090
database: {{ . }}
9191
{{- end }}
92-
{{ with .Values.recovery.owner }}
92+
{{- with .Values.recovery.owner }}
9393
owner: {{ . }}
9494
{{- end }}
9595
{{- if eq .Values.recovery.method "backup" }}
9696
backup:
9797
name: {{ .Values.recovery.backupName }}
98-
{{- else if eq .Values.recovery.method "object_store" }}
98+
{{- else if and (eq .Values.recovery.method "object_store") (eq (include "cluster.useBarmanCloudPlugin" .) "false") }}
9999
source: objectStoreRecoveryCluster
100100

101101
externalClusters:
102102
- name: objectStoreRecoveryCluster
103103
barmanObjectStore:
104104
serverName: {{ .Values.recovery.clusterName }}
105105
{{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.recovery "secretPrefix" "recovery" -}}
106-
{{- include "cluster.barmanObjectStoreConfig" $d | nindent 4 }}
107-
{{- end }}
106+
{{- include "cluster.barmanObjectStoreConfig" $d | indent 4 }}
107+
{{- else if and (eq .Values.recovery.method "object_store") (eq (include "cluster.useBarmanCloudPlugin" .) "true") }}
108+
source: origin
109+
110+
externalClusters:
111+
- name: origin
112+
plugin:
113+
name: barman-cloud.cloudnative-pg.io
114+
parameters:
115+
barmanObjectName: {{ include "cluster.fullname" $ }}-object-store
116+
serverName: {{ .Values.recovery.clusterName | default (include "cluster.fullname" .) }}
117+
{{- end }}
108118
{{- end }}
109119
{{- else }}
110120
{{ fail "Invalid cluster mode!" }}

charts/cluster/templates/objectStore.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
{{ if and (eq (include "cluster.useBarmanCloudPlugin" .) "true") .Values.backups.enabled }}
1+
{{ if eq (include "cluster.useBarmanCloudPlugin" .) "true" }}
22
apiVersion: barmancloud.cnpg.io/v1
33
kind: ObjectStore
44
metadata:
55
name: {{ include "cluster.fullname" $ }}-object-store
66
spec:
77
configuration:
8+
{{- if and (eq .Values.mode "recovery") (eq .Values.recovery.method "object_store") -}}
9+
{{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.recovery "secretPrefix" "recovery" -}}
10+
{{- include "cluster.barmanObjectStoreConfig" $d | indent 2 }}
11+
{{- else }}
812
wal:
913
compression: {{ .Values.backups.wal.compression }}
1014
{{- if .Values.backups.wal.encryption }}
@@ -17,6 +21,7 @@ spec:
1721
encryption: {{ .Values.backups.data.encryption }}
1822
{{- end }}
1923
jobs: {{ .Values.backups.data.jobs }}
20-
{{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.backups "secretPrefix" "backup" -}}
21-
{{- include "cluster.barmanObjectStoreConfig" $d | indent 2 }}
24+
{{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.backups "secretPrefix" "backup" -}}
25+
{{- include "cluster.barmanObjectStoreConfig" $d | indent 2 }}
26+
{{- end }}
2227
{{- end }}

0 commit comments

Comments
 (0)