How to Clone a MariaDB Helm Release on GKE



Robin Storage on Google Marketplace

In this tutorial, we will create a clone of the MariaDB database that has been deployed on Google Kubernetes Engine (GKE). Then we will make changes to the clone and verify that the original database has remained unaffected by changes that were done to the clone.

Before starting with this tutorial, make sure Robin Storage is installed on GKE,  your MariaDB database is deployed, has data loaded in it, and the Helm release is registered with Robin, and you have taken a snapshot of your MariaDB Helm release.

Create a clone of the MariaDB Helm Release on GKE

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.

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.

To create a clone from the existing snapshot created above, run the following command. Use the snapshot id we retrieved above.

robin clone create my-movies-clone Your_Snapshot_ID --wait

Let’s verify Robin has cloned all relevant Kubernetes resources.

kubectl get all | grep "my-movies-clone"

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 MariaDB database clone, and note the IP address.

export IP_ADDRESS=$(kubectl get service my-movies-clone-films-mariadb -o jsonpath={.spec.clusterIP})

Get Password of our mariadb database clone from Kubernetes Secret

export MARIADB_PASSWORD=$(kubectl get secret my-movies-clone-films-mariadb -o
jsonpath="{.data.mariadb-root-password}" | base64 --decode;)

To verify we have successfully created a clone of our MariaDB database, run the following command.

mysql -h $IP_ADDRESS -u root -p$MARIADB_PASSWORD testdb -e "SELECT * from movies"

You should see an output similar to the following with 9 movies.

We have successfully created a clone of our original MariaDB 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”.

mysql -h $IP_ADDRESS -u root -p$MARIADB_PASSWORD testdb -e "DELETE from movies where title = 'Super Troopers 2'"

Let’s verify the movie has been deleted.

mysql -h $IP_ADDRESS -u root -p$MARIADB_PASSWORD testdb -e "SELECT * from movies"

You should see an output similar to the following with 8 movies.

Now, let’s connect to our original MariaDB database and verify it is unaffected.

Get Service IP address of our original MariaDB database.

export MARIADB_PASSWORD=$(kubectl get secret films-mariadb -o jsonpath="{.data.mariadb-root-password}" | base64 --decode;)

Get Password of our original MariaDB database from Kubernetes Secret.

export IP_ADDRESS=$(kubectl get service films-mariadb -o jsonpath={.spec.clusterIP})

To verify that our MariaDB database is unaffected by changes to the clone, run the following command.

mysql -h $IP_ADDRESS -u root -p$MARIADB_PASSWORD testdb -e "SELECT * from movies"

You should see an output similar to the following, with all 9 movies present.

As you can see from the output above, our original MariaDB database only 9 movies and hence was unaffected by the data deletion in the clone.

This means we can work on the original MariaDB database and the cloned database simultaneously without them affecting each other. This is valuable for collaboration across teams where each team needs to perform unique sets of operations.

This concludes the clone MariaDB on GKE tutorial.


MariaDB on GKE – Deploy Tutorial


MariaDB on GKE – Snapshot Tutorial


Share with: