Resizing persistent volumes guide

Resizing persistent volumes after after initial install

Prerequisites

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:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: standard
parameters:
  type: pd-standard
provisioner: kubernetes.io/gce-pd
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:

  • Patch each PVC replacing <PVC_NAME> with the PVC to be resized and <NEW_SIZE> with the new disk size: kubectl --namespace=bugsnag patch pvc <PVC_NAME> -p '{"spec":{"resources":{"requests":{"storage":"<NEW_SIZE>Gi"}}}}'

  • Delete the pods associated with the edited PVCs: kubectl --namespace=bugsnag delete pod <POD_NAME> - This step is optional if the cloud provider backing the disks supports resizing without pod restarts.

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

kubectl --namespace=bugsnag delete --cascade=orphan statefulset <STATEFUL_SET_NAME>