Skip to content

Commit

Permalink
feat: allow simple pg_basebackup (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Bouquillon authored Aug 29, 2023
1 parent cb8506a commit 445ce56
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 4 deletions.
4 changes: 2 additions & 2 deletions charts/cnpg-cluster/templates/cluster.cnpg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ spec:
recoveryTarget:
targetTime: "{{ .Values.recovery.targetTime }}"
{{- end }}
{{- else if (and .Values.replica.enabled .Values.replica.source) }}
{{- else if (and .Values.pg_basebackup.enabled .Values.pg_basebackup.source) }}
pg_basebackup:
source: {{ .Values.replica.source }}
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
13 changes: 13 additions & 0 deletions charts/cnpg-cluster/tests/values/pg_basebackup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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
6 changes: 4 additions & 2 deletions charts/cnpg-cluster/tests/values/replication.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
imageName: ghcr.io/cloudnative-pg/postgis:14

replica:
enabled: true
source: source-cluster

pg_basebackup:
enabled: true
source: source-cluster

externalClusters:
- name: source-cluster
connectionParameters:
Expand Down
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 445ce56

Please sign in to comment.