In this series of Kubernetes, I will show you how to increase the size of the Persistent Volume or PV. I am focusing on AWS EKS in this tutorial but you can also try this on other platforms.
Sometimes we need to increase the size of the PV so you can just follow this article to do that.
Read Also: Get Kubernetes events according to date using kubectl
1. Check StorageClass Settings
First of all, you need to make sure the StorageClass has allowVolumeExpansion enabled.
~ kubectl get storageclass gp2 -o yaml
allowVolumeExpansion: true #This setting should be enabled
So now we can go ahead and increase the PVC.
Note: only dynamically provisioned pvc can be resized and the storageclass that provisions the pvc must support resize
Read Also: Kubernetes get pods on a Specific Node
2. Increase the size of the persistent volume
Now you can increase the storage size of the PVC. ( You cannot decrease the size of the volume)
~ kubectl edit pvc [claim-name] -n namespace
storage: 30Gi # increase the value here
Save the file and check the status of the Persistent Volume (PV) associated with PVC.
3. Delete or Restart the Pod
When you edit the PVC you will receive a message like this.
message: Waiting for user to (re-)start a pod to finish file system resize of volume on the node.
So, let’s restart the pods on which volume is mounted.
kubectl delete pod [pod-name] -n namespace
After a few minutes, the pod will be up and running with the updated size of the volume.
Please let me know if you have any issues using this tutorial.
Leave a Reply