Skip to content

Commit 4f461ef

Browse files
authored
K8SPXC-1453 Added a section hor (#222)
to use dataSource dquote> dquote> new file: docs/data-source.md modified: mkdocs-base.yml
1 parent 92eead7 commit 4f461ef

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Diff for: docs/data-source.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Clone a cluster with the same data set
2+
3+
A good practice is to test a new functionality or an upgraded version of the database in a testing / staging environment. As a developer, you would want the data in the staging database cluster, so that your applications can start immediately.
4+
5+
The [`dataSource` :octicons-link-external-16:](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#volume-cloning) functionality allows doing just that. Instead of creating a new PVC for a new cluster, you can clone the existing one. This enables you to spin up a new cluster with the data in it almost in no time which is especially beneficial if you use CI/CD for that.
6+
7+
For example, you have the production Percona XtraDB Cluster `cluster1`. To test a new feature in your app, you need a staging cluster `cluster2` with the data set from `cluster1`.
8+
9+
To create it, create the `cluster2-cr.yaml` Custom Resource manifest. You can use the existing [`deploy/cr.yaml` ](https://raw.githubusercontent.com/percona/percona-xtradb-cluster-operator/{{release}}/deploy/cr.yaml) for convenience. Specify the PVC from `cluster1` as the `dataSource` for it:
10+
11+
```yaml
12+
pxc:
13+
volumeSpec:
14+
persistentVolumeClaim:
15+
dataSource:
16+
name: cluster1-pvc
17+
kind: PersistentVolumeClaim
18+
19+
```
20+
21+
This configuration instructs the Operator to create a direct clone of the PVC from `cluster1`. If you have a snapshot of the PVC, you can use that as a data source for your staging cluster. Here’s how you define it:
22+
23+
```yaml
24+
persistentVolumeClaim:
25+
dataSource:
26+
name: cluster1-pvc-snapshot1
27+
kind: VolumeSnapshot
28+
apiGroup: snapshot.storage.k8s.io
29+
```
30+
31+
To create a database cluster, apply the `cluster2-cr.yaml`.

Diff for: mkdocs-base.yml

+1
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ nav:
216216
- "Add sidecar containers": sidecar.md
217217
- "Restart or pause the cluster": pause.md
218218
- "Crash recovery": recovery.md
219+
- data-source.md
219220

220221
- Troubleshooting:
221222
- "Initial troubleshooting": debug.md

0 commit comments

Comments
 (0)