Resizing Persistent Volume Claim in Kubernetes Cluster
When you require additional storage for your application, you may need to resize a Persistent Volume Claim (PVC) in the Kubernetes cluster. This document provides step-by-step instructions to resize a PVC in a Kubernetes cluster.
Prerequisites
Your PVC's StorageClass has to support volume expansion. Verify that your StorgeClass has
allowVolumeExpansion: true
Ensure you have the necessary permissions to edit PVCs and resize volumes.
Resizing a PVC
There may be downtime when resizing a PVC in Kubernetes, especially when transferring data or resizing file systems. To securely resize a PVC, turn off the related service and follow the instructions below.
Identify the PVC you want to resize. Run the below command.
Identify the pods that are using this PVC.
You must end the running application in order to safely resize the PVC. If the PVC is attached to a Deployment, StatefulSet, or another workload, scale it down to zero replicas. For a Deployment
For a StatefulSet
Confirm that the pods have been scaled down.
Edit the PVC to update the
spec.resources.requests.storage
field with the new size. Run the following command.Edit the storage field to Increase the storage size. For example, change 10GB to 20GB.
After updating the PVC, check the status to ensure the resize operation succeeds.
After resizing the PVC and verifying that everything is in order, scale the deployment or stateful set back to its initial number of replicas. For a Deployment
For a StatefulSet
Verify that the pods are running
Note:
You can use the Rancher UI to resize the PVC by following the procedures listed above.
Last updated