1. Overview
Kubernetes supports in-place Persistent Volume expansion, allowing you to increase the size of an existing Persistent Volume without losing existing data.
During the expansion process:
- Block storage is expanded at the Cloud infrastructure layer.
- The filesystem is resized to use the newly available storage capacity.
- Existing data remains unchanged. No data is deleted, moved, or modified.
2. Prerequisites
Before expanding a Persistent Volume, verify the following requirements.
StorageClass Configuration
The StorageClass must have volume expansion enabled:
allowVolumeExpansion: trueVolume Expansion
Only increasing the volume size is supported.
Example:
5Gi → 10Gi
Shrinking an existing volume is not supported and will fail validation.
Verify the CSI Driver
Check that the CSI driver is running:
kubectl get pods -n kube-system | grep cinderAll cinder.csi.openstack.org pods should be in the Running state.
3. Expand the Persistent Volume
This procedure uses YAML manifests to perform the volume expansion.
Step 1: Update the PVC Storage Request
Open the PersistentVolumeClaim YAML file.
Example:
pvc.yaml
Update the requested storage size:
spec:
resources:
requests:
storage: 10GiIn this example, the volume size is increased from 5Gi to 10Gi.
Apply the updated configuration:
kubectl apply -f pvc.yamlStep 2: Resize the Filesystem
After the volume has been expanded, the filesystem must also be resized to use the additional capacity.
Note: In this environment using ext4/xfs, a pod restart is required.
If Using a Deployment
Run:
kubectl rollout restart deployment <deployment-name>If Using a Standalone Pod
Run:
kubectl apply -f pod.ymlKubernetes will:
- Re-attach the expanded volume.
- Automatically expand the filesystem when the volume is mounted.
4. Verify the Volume Expansion
After completing the expansion, verify that the new storage size is available.
Check the PVC Status
Run:
kubectl get pvc <pvc-name>Verify that:
- The PVC status is Bound.
- The new storage size is displayed.
Verify the Storage Inside the Pod
Run:
kubectl exec <pod-name> — df -h /dataCheck the Size column and confirm that the updated storage capacity is displayed.
5. Safety and Recovery
Data Integrity
During volume expansion:
- The expansion occurs at the end of the partition.
- Existing data remains unchanged and safe.
Expansion Failure
If the expansion fails, for example because of insufficient quota:
- The PVC status will remain Expanding.
- The pod will continue operating with the original storage size.
- After the issue is resolved, the expansion process will automatically continue.
Best Practice
- Perform Persistent Volume expansion during a low-traffic period.
- This helps reduce the impact of any required pod restarts.
6. Summary
Kubernetes supports safe, in-place Persistent Volume expansion without affecting existing data.
The expansion process requires:
- A StorageClass with volume expansion enabled.
- Updating the requested storage size in the YAML file.
- Restarting the pod.
- Verifying the new storage size after expansion.