Persistent Volume Expansion Kubernetes
Expand PersistentVolumeClaims online without downtime. allowVolumeExpansion, filesystem resize, StatefulSet PVC expansion.
π‘ Quick Answer: Set
allowVolumeExpansion: trueon your StorageClass, thenkubectl edit pvc <name>and increasespec.resources.requests.storage. The volume and filesystem expand automatically (online for most CSI drivers).
The Problem
Applications grow β databases fill up, log volumes expand, ML datasets accumulate. You need to increase PVC size without downtime, pod restarts, or data migration. Kubernetes supports online volume expansion, but it requires proper StorageClass configuration.
The Solution
Enable Volume Expansion
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: expandable-ssd
provisioner: ebs.csi.aws.com
parameters:
type: gp3
allowVolumeExpansion: true
reclaimPolicy: RetainExpand a PVC
# Check current size
kubectl get pvc data-volume -o jsonpath='{.spec.resources.requests.storage}'
# 10Gi
# Expand to 50Gi
kubectl patch pvc data-volume -p '{"spec":{"resources":{"requests":{"storage":"50Gi"}}}}'
# Monitor expansion
kubectl get pvc data-volume -o jsonpath='{.status.conditions[*].type}'
# FileSystemResizePending β (empty when complete)
# Verify new size
kubectl exec my-pod -- df -h /data
# /dev/nvme1n1 50G 8.2G 42G 17% /dataStatefulSet PVC Expansion
# StatefulSet PVCs are named: <volumeClaimTemplate-name>-<pod-name>
# Expand each one individually
for i in 0 1 2; do
kubectl patch pvc data-db-$i -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'
doneβ οΈ You cannot change
volumeClaimTemplatesin a StatefulSet. Expand existing PVCs individually.
graph LR
EDIT[kubectl patch pvc<br/>50Gi β 100Gi] --> CSI[CSI Driver<br/>Expand block device]
CSI --> FS[Filesystem Resize<br/>ext4/xfs online resize]
FS --> POD[Pod sees new size<br/>df -h shows 100Gi]Common Issues
PVC stuck in FileSystemResizePending
Some CSI drivers require pod restart to trigger filesystem resize. Delete the pod β StatefulSet recreates it, and the filesystem expands on mount.
βstorageclass does not allow volume expansionβ
The StorageClass has allowVolumeExpansion: false (or unset). You canβt change it retroactively for existing PVCs. Create a new StorageClass with expansion enabled.
Best Practices
- Always set
allowVolumeExpansion: trueon production StorageClasses - You can only increase PVC size β shrinking is not supported
- Expand during low-traffic periods β filesystem resize may briefly increase I/O latency
- Monitor PVC usage with Prometheus β alert at 80% capacity to expand proactively
- Test expansion in staging before production β verify your CSI driver supports online resize
Key Takeaways
- PVC expansion requires
allowVolumeExpansion: trueon the StorageClass kubectl patch pvcto increase storage β CSI driver + filesystem resize handles the rest- StatefulSet PVCs must be expanded individually (canβt change volumeClaimTemplates)
- Online expansion works with most CSI drivers (EBS, GCE PD, Azure Disk, Ceph)
- You can only grow PVCs β shrinking is never supported

Recommended
Kubernetes Recipes β The Complete Book100+ production-ready patterns with detailed explanations, best practices, and copy-paste YAML. Everything in one place.
Get the Book βLearn by Doing
CopyPasteLearn β Hands-on Cloud & DevOps CoursesMaster Kubernetes, Ansible, Terraform, and MLOps with interactive, copy-paste-run lessons. Start free.
Browse Courses βπ Deepen Your Skills β Hands-on Courses
Courses by CopyPasteLearn.com β Learn IT by Doing
