Resize
We can resize the volume by updating the PVC yaml to the desired size and applying it. The LVM Driver will take care of expanding the volume via lvextend command using "-r" option which will resize the filesystem.
note
Online Volume Expansion for Block
mode and btrfs
Filesystem mode is supported only from K8s 1.23+ version.
For resize, storageclass that provisions the PVC must support resize. We should have allowVolumeExpansion as true in storageclass.
Create the PVC using the above storage class.
OpenEBS LVM driver supports Online Volume expansion, which means that we can expand the volume even if volume is being used by the application and we also do not need to restart the application to use the expanded volume, the LVM Driver will take care of making the space available to it.
note
File system expansion does not happen until an application pod references the resized volume, so if no pods referencing the volume are running, file system expansion will not happen.
Deploy the application using the PVC. Here is a sample yaml for the application:
Check the current PVC status.
Exec into the application pod and check the size.
Deploy the application using the PVC which supports volume expansion. Once the application pod is deployed, we will expand the PVC to 5Gi from 4Gi. Edit the PVC yaml and update the size to 5Gi and apply it:
Apply the above yaml which will resize the volume.
Check the PVC yaml.
See in the message that it is waiting on FileSystemResizePending. The resize request will go to the node where the application pod is running. The LVM driver node agent will resize the filesytem for the application. Keep checking the PVC yaml for FileSystemResizePending to go away, once PVC is resized, the yaml will look like this:
Also, we can exec into the application pod and verify the same:
As we can see the volume mount point /datadir
is showing that it has been resized.