Resize Persistent Volume in Kubernetes

You can only resize volumes containing a file system if the file system is XFS, Ext3, or Ext4. When a volume contains a file system, the file system is only resized when a new Pod is using the PersistentVolumeClaim in ReadWrite mode. File system expansion is either done when a Pod is starting up or when a Pod is running and the underlying file system supports online expansion.

First of all, the Storage Class must have the AllowVolumeExpansion: True configured:

AllowVolumeExpansion:  True

If it has not been setup yet, you can update it. For example

$ kubectl patch storageclass/"glusterfs" \
  --namespace "default" \
  --patch '{"allowVolumeExpansion": true}'

Then you need to edit or patch the current PVC config to reflect the new size. For example, I want to resize the glusterfs-test-pvc from 5G to 8G.

$ kubectl patch pvc/"glusterfs-test-pvc" \
 --namespace "default" \
 --patch '{"spec": {"resources": {"requests": {"storage": "8Gi"}}}}'

The full example:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s