Skip to content

K8SPXC-1453 Added a section how to use dataSource #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed __pycache__/main.cpython-311.pyc
Binary file not shown.
31 changes: 31 additions & 0 deletions docs/data-source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Clone a cluster with the same data set

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.

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.

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`.

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:

```yaml
pxc:
volumeSpec:
persistentVolumeClaim:
dataSource:
name: cluster1-pvc
kind: PersistentVolumeClaim

```

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:

```yaml
persistentVolumeClaim:
dataSource:
name: cluster1-pvc-snapshot1
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io
```

To create a database cluster, apply the `cluster2-cr.yaml`.
1 change: 1 addition & 0 deletions mkdocs-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ nav:
- "Add sidecar containers": sidecar.md
- "Restart or pause the cluster": pause.md
- "Crash recovery": recovery.md
- data-source.md

- Troubleshooting:
- "Initial troubleshooting": debug.md
Expand Down