Kubernetes Tutorial: How to Expand MySQL Persistent Volume With No Downtime on GKE

This tutorial is a walk-through of how to expand MySQL persistent volume with no downtime on Google Kubernetes Engine (GKE) by Certified Kubernetes Administrator (CKA) and Application Developer (CKAD) Janakiram MSV.

TRANSCRIPT:

Janakiram MSV: Hi. In this video, I’m going to show you how to expand a Portworx storage volume on the fly. So we’re going to dynamically expand the volume size that is currently backing one of the stateful workloads running in production. So in our case, we have a MySQL database running on Google Kubernetes engine and Portworx. So let’s go ahead and see how to expand the volume size. So let’s first take a look at the volume that is associated with our MySQL workload. So we stored the volume name in this environment variable called vol, and using that, we are going to query the status of this volume. Then we grab the pod name running the Portworx DaemonSet, a pod that’s a part of the DaemonSet. And with that, we can actually explore the current volume information.

So now we are invoking pxctl, the binary that is available as a part of the Portworx installation, and we are passing the volume name that we grabbed in the very first step to inspect it. And it is going to show us some interesting information. The most important thing to note here is the size of this volume is currently 1GB, and this is based on the PVC and the dynamic provision volume that we created in one of the previous steps. Alright, now our goal is to double the capacity of this volume, so we’ll go from 1GB to 2GB. So it’s better to access the node, because we are going to get into the node, the shell of the node, and then we’ll execute a set of commands. So first, I’m going to grab the node name where we have MySQL running. You can actually get any node, it doesn’t matter, but I’m currently grabbing the node name where the MySQL pod is currently scheduled. And then we are going to ssh into the node.

So I’m using gcloud compute ssh, you can use a standard ssh command to get into the node. And now, we are inside one of the worker nodes of the Kubernetes cluster. Once we have this, we can, again, grab the pod name that is associated with the PVC and the storage volume created by Portworx. Alright, so this will show us the volume ID backing the PVC that we created in one of the previous steps. Now we can inspect this volume. So when we run pxctl volume inspect on the volume name, we get to see exactly what we have seen when we queried it from the pod, so it’s exactly the same information. Now, we’re going to run this command called pxctl volume update, the volume name and size equal to two, and this will ensure that we are increasing the capacity by 2x. So from 1GB, we are going to expand the volume to 2GB.

Now, we see the response that volume update has been successful, it’s time for us to query the same volume. So next time, when we query this, we instantly notice that the size has gone from 1GB to 2GB, and this is almost with no downtime and dynamically expanding a volume that is currently associated with the production workload. This ability will ensure that we are never running out of space and we can always expand the volume that is backing a production workload running on top of Kubernetes and Portworx. I hope you found this video useful. Thanks for watching.