PersistentVolumes created using the provided StorageClasses can be resized.
Note
PersistentVolumes can only be expanded, not reduced in size.
$ kubectl get storageclass
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
b1.sr-r3-nvme-1000 (default) cinder.csi.openstack.org Retain Immediate true 6d3h
b1.sr-r3-nvme-2500 cinder.csi.openstack.org Retain Immediate true 6d3h
b1.sr-r3-nvme-5000 cinder.csi.openstack.org Retain Immediate true 6d3h
b1.standard cinder.csi.openstack.org Retain Immediate true 6d3h
To initiate a resize, patch the PersistentVolumeClaim and set
spec.resources.requests.storage to an increased size.
$ kubectl get pvc test-pvc -o jsonpath='{.spec.resources.requests.storage}'
1Gi
$ kubectl patch pvc test-pvc --type merge -p '{"spec":{"resources":{"requests":{"storage":"2Gi"}}}}'
persistentvolumeclaim/test-pvc patched
The Cinder CSI will begin resizing the volume. The filesystem will also be automatically resized to fit the new volume.
We can see these events and verify the size is reflected inside the new pod:
$ kubectl get events
LAST SEEN TYPE REASON OBJECT MESSAGE
4m2s Normal Provisioning persistentvolumeclaim/test-pvc External provisioner is provisioning volume for claim "default/test-pvc"
4m Normal ProvisioningSucceeded persistentvolumeclaim/test-pvc Successfully provisioned volume pvc-48a22d68-67ef-47fe-a14c-6cfcb233b1a0
74s Normal ExternalExpanding persistentvolumeclaim/test-pvc waiting for an external controller to expand this PVC
74s Normal Resizing persistentvolumeclaim/test-pvc External resizer is resizing volume pvc-48a22d68-67ef-47fe-a14c-6cfcb233b1a0
72s Normal Resizing persistentvolumeclaim/test-pvc External resizer is resizing volume pvc-48a22d68-67ef-47fe-a14c-6cfcb233b1a0
71s Normal FileSystemResizeRequired persistentvolumeclaim/test-pvc Require file system resize of volume on node
62s Normal FileSystemResizeSuccessful persistentvolumeclaim/test-pvc MountVolume.NodeExpandVolume succeeded for volume "pvc-48a22d68-67ef-47fe-a14c-6cfcb233b1a0" test-cluster-n6x24o5olu43-default-worker-4pbnz-9fwlh
$ kubectl exec deployment/test-app -- df -h /data
Filesystem Size Used Avail Use% Mounted on
/dev/vdb 2.0G 32K 2.0G 1% /data