How do you resize a live PersistentVolume?
online volume expansion.
edit the PVC's requested size upward; the StorageClass must set allowVolumeExpansion true and the CSI driver must support expansion, ideally online so no Pod restart is needed; shrinking is not allowed.
WHAT THIS TESTS Whether you know the supported expansion path, its driver and StorageClass prerequisites, and the constraints like no-shrink.
A GOOD ANSWER COVERS To grow storage you edit the PersistentVolumeClaim and raise its requested capacity; you do not edit the PV's capacity yourself. Kubernetes detects the larger request and, through the external-resizer sidecar, calls the CSI driver's ControllerExpandVolume to enlarge the backend disk, then the filesystem is grown. For prerequisites, the StorageClass used to provision the volume must have allowVolumeExpansion set to true, otherwise the API rejects the larger request. The CSI driver must implement volume expansion capabilities. Filesystem volumes also need a node-side resize via NodeExpandVolume so the filesystem uses the new space. If the driver supports online or in-use expansion, the volume can grow while the Pod keeps running; if not, the filesystem resize may require the Pod to be recreated so the volume is remounted. A hard rule across all drivers is that volumes can only grow, never shrink. You can watch the PVC's Conditions, such as FileSystemResizePending, to track progress.
COMMON WRONG ANSWERS Editing the PV capacity directly instead of the PVC. Forgetting allowVolumeExpansion on the StorageClass. Assuming shrinking works. Believing every expansion is online and never needs a Pod restart. Ignoring the node-side filesystem resize.
LIKELY FOLLOW-UPS What does FileSystemResizePending mean? Which CSI drivers support online expansion? Why is shrinking unsafe? How does raw block volume expansion differ from filesystem expansion?
ONE CONCRETE EXAMPLE With a gp3 StorageClass that has allowVolumeExpansion true, you patch the PVC from 20Gi to 50Gi; the AWS EBS CSI driver expands the disk and grows the ext4 filesystem online, and the Pod sees 50Gi without restarting.
Read the original → kubernetes.io
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.