Skip to content

Commit

Permalink
feat: allow simple pg_basebackup
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Bouquillon committed Aug 28, 2023
1 parent cb8506a commit a2267b6
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions charts/cnpg-cluster/templates/cluster.cnpg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ spec:
{{- else if (and .Values.replica.enabled .Values.replica.source) }}
pg_basebackup:
source: {{ .Values.replica.source }}
{{- else if (and .Values.pg_basebackup.enabled .Values.pg_basebackup.source) }}
pg_basebackup:
source: {{ .Values.pg_basebackup.source }}
{{- else }}
initdb:
database: {{ .Values.dbName }}
Expand Down
13 changes: 13 additions & 0 deletions charts/cnpg-cluster/tests/__snapshot__/cnpg-cluster_test.yaml.snap
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@ cluster with enabled backup and recovery:
cluster:
name: RELEASE-NAME-cnpg-cluster
schedule: 1 2 3 * * 0
cluster with pg_basebackup:
1: |
- connectionParameters:
dbname: app
host: some-host-to-replicate-from
user: postgres
name: source-cluster
password:
key: password
name: source-secret-for-source-replication
2: |
pg_basebackup:
source: source-cluster
cluster with recovery enabled:
1: |
bootstrap:
Expand Down
10 changes: 10 additions & 0 deletions charts/cnpg-cluster/tests/cnpg-cluster_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,13 @@ tests:
- template: cluster.cnpg.yaml
matchSnapshot:
path: spec.replica
- it: cluster with pg_basebackup
values:
- ./values/pg_basebackup.yaml
asserts:
- template: cluster.cnpg.yaml
matchSnapshot:
path: spec.externalClusters
- template: cluster.cnpg.yaml
matchSnapshot:
path: spec.bootstrap
15 changes: 15 additions & 0 deletions charts/cnpg-cluster/tests/values/pg_basebackup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
imageName: ghcr.io/cloudnative-pg/postgis:14

pg_basebackup:
enabled: true
source: source-cluster

externalClusters:
- name: source-cluster
connectionParameters:
host: some-host-to-replicate-from
user: postgres
dbname: app
password:
name: source-secret-for-source-replication
key: password
5 changes: 5 additions & 0 deletions charts/cnpg-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,8 @@ postInitApplicationSQLRefs:
# secretRefs:
# - name: post-init-sql-secret
# key: secret.sql

#
pg_basebackup:
enabled: false
source:

0 comments on commit a2267b6

Please sign in to comment.