forked from cloudnative-pg/cloudnative-pg
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replica cluster bootstrap via VolumeSnapshot (cloudnative-pg#2647)
The codebase already supported creating a replica cluster from a volume snapshot. This patch adds the documentation and the E2e tests for it. Signed-off-by: Niccolò Fei <[email protected]> Signed-off-by: Armando Ruocco <[email protected]> Signed-off-by: Leonardo Cecchi <[email protected]> Co-authored-by: Armando Ruocco <[email protected]> Co-authored-by: Leonardo Cecchi <[email protected]>
- Loading branch information
1 parent
b5f594a
commit c2ca044
Showing
15 changed files
with
617 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: postgresql.cnpg.io/v1 | ||
kind: Backup | ||
metadata: | ||
name: backup-with-volume-snapshot | ||
spec: | ||
method: volumeSnapshot | ||
cluster: | ||
name: cluster-example-with-volume-snapshot |
54 changes: 54 additions & 0 deletions
54
docs/src/samples/cluster-example-replica-from-volume-snapshot.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
apiVersion: postgresql.cnpg.io/v1 | ||
kind: Cluster | ||
metadata: | ||
name: cluster-example-replica-from-snapshot | ||
spec: | ||
instances: 1 | ||
|
||
storage: | ||
storageClass: csi-hostpath-sc | ||
size: 1Gi | ||
walStorage: | ||
storageClass: csi-hostpath-sc | ||
size: 1Gi | ||
|
||
bootstrap: | ||
recovery: | ||
source: cluster-example-with-volume-snapshot | ||
volumeSnapshots: | ||
storage: | ||
name: cluster-example-with-volume-snapshot-2-1692618163 | ||
kind: VolumeSnapshot | ||
apiGroup: snapshot.storage.k8s.io | ||
walStorage: | ||
name: cluster-example-with-volume-snapshot-2-wal-1692618163 | ||
kind: VolumeSnapshot | ||
apiGroup: snapshot.storage.k8s.io | ||
|
||
replica: | ||
enabled: true | ||
source: cluster-example-with-volume-snapshot | ||
|
||
externalClusters: | ||
- name: cluster-example-with-volume-snapshot | ||
|
||
connectionParameters: | ||
host: cluster-example-with-volume-snapshot-rw.default.svc | ||
user: postgres | ||
dbname: postgres | ||
password: | ||
name: cluster-example-with-volume-snapshot-superuser | ||
key: password | ||
|
||
barmanObjectStore: | ||
destinationPath: s3://backups/ | ||
endpointURL: http://minio:9000 | ||
s3Credentials: | ||
accessKeyId: | ||
name: minio | ||
key: ACCESS_KEY_ID | ||
secretAccessKey: | ||
name: minio | ||
key: ACCESS_SECRET_KEY | ||
wal: | ||
maxParallel: 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
docs/src/samples/cluster-example-with-volume-snapshot.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: postgresql.cnpg.io/v1 | ||
kind: Cluster | ||
metadata: | ||
name: cluster-example-with-volume-snapshot | ||
spec: | ||
instances: 3 | ||
primaryUpdateStrategy: unsupervised | ||
|
||
# Persistent storage configuration | ||
storage: | ||
storageClass: csi-hostpath-sc | ||
size: 1Gi | ||
walStorage: | ||
storageClass: csi-hostpath-sc | ||
size: 1Gi | ||
|
||
# Backup properties | ||
backup: | ||
volumeSnapshot: | ||
className: csi-hostpath-snapclass | ||
barmanObjectStore: | ||
destinationPath: s3://backups/ | ||
endpointURL: http://minio:9000 | ||
s3Credentials: | ||
accessKeyId: | ||
name: minio | ||
key: ACCESS_KEY_ID | ||
secretAccessKey: | ||
name: minio | ||
key: ACCESS_SECRET_KEY | ||
wal: | ||
compression: gzip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
tests/e2e/fixtures/replica_mode_cluster/cluster-replica-from-backup.yaml.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
apiVersion: postgresql.cnpg.io/v1 | ||
kind: Cluster | ||
metadata: | ||
name: cluster-replica-from-backup | ||
spec: | ||
instances: 1 | ||
|
||
# Persistent storage configuration | ||
storage: | ||
storageClass: ${E2E_DEFAULT_STORAGE_CLASS} | ||
size: 1Gi | ||
walStorage: | ||
storageClass: ${E2E_DEFAULT_STORAGE_CLASS} | ||
size: 1Gi | ||
|
||
replica: | ||
enabled: true | ||
source: cluster-replica-src | ||
|
||
bootstrap: | ||
recovery: | ||
source: cluster-replica-src | ||
|
||
externalClusters: | ||
- name: cluster-replica-src | ||
|
||
connectionParameters: | ||
host: cluster-replica-src-rw | ||
user: postgres | ||
dbname: postgres | ||
port: "5432" | ||
password: | ||
name: cluster-replica-src-superuser | ||
key: password | ||
|
||
barmanObjectStore: | ||
destinationPath: s3://cluster-backups/ | ||
endpointURL: http://minio-service:9000 | ||
s3Credentials: | ||
accessKeyId: | ||
name: backup-storage-creds | ||
key: ID | ||
secretAccessKey: | ||
name: backup-storage-creds | ||
key: KEY | ||
wal: | ||
compression: gzip |
56 changes: 56 additions & 0 deletions
56
tests/e2e/fixtures/replica_mode_cluster/cluster-replica-from-snapshot.yaml.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
apiVersion: postgresql.cnpg.io/v1 | ||
kind: Cluster | ||
metadata: | ||
name: cluster-replica-from-snapshot | ||
spec: | ||
instances: 1 | ||
|
||
# Persistent storage configuration | ||
storage: | ||
storageClass: ${E2E_CSI_STORAGE_CLASS} | ||
size: 1Gi | ||
walStorage: | ||
storageClass: ${E2E_CSI_STORAGE_CLASS} | ||
size: 1Gi | ||
|
||
replica: | ||
enabled: true | ||
source: cluster-replica-src | ||
|
||
bootstrap: | ||
recovery: | ||
source: cluster-replica-src | ||
volumeSnapshots: | ||
storage: | ||
name: ${REPLICA_CLUSTER_SNAPSHOT_NAME_PGDATA} | ||
kind: VolumeSnapshot | ||
apiGroup: snapshot.storage.k8s.io | ||
walStorage: | ||
name: ${REPLICA_CLUSTER_SNAPSHOT_NAME_PGWAL} | ||
kind: VolumeSnapshot | ||
apiGroup: snapshot.storage.k8s.io | ||
|
||
externalClusters: | ||
- name: cluster-replica-src | ||
|
||
connectionParameters: | ||
host: cluster-replica-src-rw | ||
user: postgres | ||
dbname: postgres | ||
port: "5432" | ||
password: | ||
name: cluster-replica-src-superuser | ||
key: password | ||
|
||
barmanObjectStore: | ||
destinationPath: s3://cluster-backups/ | ||
endpointURL: http://minio-service:9000 | ||
s3Credentials: | ||
accessKeyId: | ||
name: backup-storage-creds | ||
key: ID | ||
secretAccessKey: | ||
name: backup-storage-creds | ||
key: KEY | ||
wal: | ||
compression: gzip |
Oops, something went wrong.