Resizing persistent volumes guide

Resizing persistent volumes after after initial install


Before getting started with resizing persistent volumes, you’ll need the following in advance:

Ensure line “allowVolumeExpansion: true” exists in the default storage class. If this does not already exist in the default storage class, this can be done by editing the default storage class:

  • Find the default storage class by running kubectl get storageclass it will have (default) next to it.

  • Edit the storage class kubectl edit storageclass <NAME> and add allowVolumeExpansion: true so it looks like the following:

kind: StorageClass
  name: standard
  type: pd-standard
allowVolumeExpansion: true
reclaimPolicy: Delete

Resizing persistent volumes

Currently as of Kubernetes 1.16, it is not possible to resize the disks of a StatefulSet by editing the StatefulSet, instead each PVC used by the StatefulSet pods needs to be edited and deleted for the new size to take affect:

  • Edit each PVC kubectl --namespace=<NAMESPACE> edit pvc <PVC_NAME> and modify to the value you wish to set the new disk size to.

  • Delete the pods associated with the edited PVCs: kubectl --namespace=<NAMESPACE> delete pod <POD_NAME>

  • Recreate the StatefulSet to keep things consistent by first deleting the StatefulSet without deleting the Pods and causing further downtime:

kubectl --namespace=<NAMESPACE> delete --cascade=false statefulset <STATEFUL_SET_NAME>