In this tutorial, we will create a clone of the MySQL database that is deployed on OpenShift. We will then make changes to the clone and verify that the original database has remained unaffected by changes that were done to the clone.
Before you begin this tutorial, make sure you have installed Robin Storage on your existing OpenShift cluster, your MySQL database is deployed on OpenShift, has data loaded in it, and the Helm release is registered with Robin and you have taken a snapshot of your deployed MySQL database.
How to Clone a MySQL Database on OpenShift
Robin lets you clone not just the storage volumes (PVCs) but the entire database application including all its resources such as Pods, StatefulSets, PVCs, Services, ConfigMaps, etc. with a single command.
Application cloning improves the collaboration across Dev/Test/Ops teams. Teams can share app+data quickly, reducing the procedural delays involved in re-creating environments. Each team can work on their clone without affecting other teams. Clones are useful when you want to run a report on a database without affecting the source database application, or for performing UAT tests or for validating patches before applying them to the production database, etc.
Robin clones are ready-to-use “thin copy” of the entire app/database, not just storage volumes. Thin-copy means that data from the snapshot is NOT physically copied, therefore clones can be made very quickly. Robin clones are fully-writable and any modifications made to the clone are not visible to the source app/database.
To create a clone from the existing MySQL database snapshot created earlier, run the following command. Use the snapshot id from the snapshot tutorial.
Let’s verify Robin has cloned all relevant Kubernetes resources.
You should see an output similar to below.
Notice that Robin automatically clones all the required Kubernetes resources, not just storage volumes (PVCs), that are required to stand up a fully-functional clone of our database. After the clone is complete, the cloned database is ready for use.
Get Service IP address of our MySQL database clone, and note the IP address.
Get Password of our MySQL database clone from Kubernetes Secret
To verify we have successfully created a clone of our MySQL database, run the following command.
You should see an output similar to the following with 9 movies.
We have successfully created a clone of our original MySQL database, and the cloned database also has a table called “movies” with 9 rows, just like the original.
Now, let’s make changes to the clone and verify the original database remains unaffected by changes to the clone. Let’s delete the movie called “Super Troopers 2”.
Let’s verify the movie has been deleted.
You should see an output similar to the following with 8 movies.
Now, let’s connect to our original MySQL database and verify it is unaffected.
Get Service IP address of our original MySQL database.
Get Password of our original MySQL database from Kubernetes Secret.
To verify that our MySQL database is unaffected by changes to the clone, run the following command. Let’s connect to “testdb” and check the record.
You should see an output similar to the following, with all 9 movies present.
This means we can work on the original MySQL database and the cloned database simultaneously without affecting each other. This is valuable for collaboration across teams where each team needs to perform a unique set of operations. To see a list of all clones created by Robin run the following command.
Now let’s delete the clone. Clone is just any other Robin app so it can be deleted using ‘robin app delete’ command.
This concludes the Clone MySQL on OpenShift tutorial.