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.12, 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:

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

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

  3. 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>
  1. Configure the disk size under Storage section by reconfiguring Bugsnag and applying the resulting YAML.