Volume Resize

Explore this Page

Overview

The Resize feature enables you to increase the size of a Persistent Volume (PV) after it has been provisioned. This is achieved by resizing a dynamically provisioned Persistent Volume Claim (PVC), provided the associated StorageClass has the allowVolumeExpansion parameter set to true.

By enabling volume resizing, you can efficiently manage storage without the need to predict future capacity requirements upfront. A volume can initially be created based on current needs and expanded later as demand increases.

The Replicated PV Mayastor CSI driver supports volume expansion in both ONLINE and OFFLINE states.

Requirements

Before attempting to resize a volume, ensure the following conditions are met:

  • Only dynamically provisioned PVCs can be resized.
  • Only volume expansion is supported. Shrinking (reducing) a volume is not permitted.
  • The StorageClass used must support resizing. The allowVolumeExpansion parameter is set to true by default.
  • The disk pools hosting the volume replicas must have sufficient available capacity.
  • All volume replicas must be in the Online state.

Resizing a PVC (Example)

  1. Define a StorageClass with Volume Expansion Enabled.

    Copy
    Define a StorageClass with allowVolumeExpansion enabled
    cat <<EOF | kubectl create -f -
    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      name: mayastor-1
    parameters:
      protocol: nvmf
      repl: "1"
    provisioner: io.openebs.csi-mayastor
    allowVolumeExpansion: true
    EOF
  2. Create a PVC.

    Copy
    Create a PVC
    cat <<EOF | kubectl create -f -
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: ms-volume-claim
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 1Gi
      storageClassName: mayastor-1
    EOF
  3. Deploy an application pod that uses the ms-volume-claim PVC.

  4. Update the PVC definition to request a larger size.

    Copy
    Edit the PVC to expand its capacity
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: ms-volume-claim
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
         requests:
            storage: 2Gi #Modified Size
      storageClassName: mayastor-1
  5. Verify the Volume Resize.

    Copy
    Check that the PVC has been resized
    kubectl get pvc ms-volume-claim
    Copy
    Sample Output
    NAME               STATUS    VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
    ms-volume-claim    Bound     pvc-e6aa58e7-84e9-457a-ba21-9819558cf360   2Gi       RWO             mayastor-1     54s
    Copy
    Check the associated PV
    kubectl get pv
    Copy
    Sample Output
    NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS    CLAIM    STORAGECLASS   REASON    AGE
    pvc-e6aa58e7-84e9-457a-ba21-9819558cf360   2Gi       RWO             Delete  

Current Limitations and Expected Behavior

For OFFLINE volume expansion (i.e., when the application pod is not running), the file system is automatically expanded when the pod is restarted and the volume is reattached.

During this process, a short delay may occur between the NodePublishVolume and NodeExpandVolume CSI calls. If an application queries the file system during this window, it may still reflect the old size. Restarting the application pod typically resolves this issue.

If a volume is expanded during a system upgrade and the underlying I/O engine has not yet been upgraded with the necessary fixes, I/O operations on the newly expanded portion of the volume may fail. It is strongly recommended to wait for the upgrade to complete before initiating volume expansion.

Benefits of Resize

  • Enables on-demand capacity growth without downtime.
  • Helps avoid over-provisioning and reduce storage waste.
  • Adapts storage to changing application workloads seamlessly.
  • Reduces operational overhead by eliminating the need for manual migration.
  • Enhances flexibility and agility in storage management.

Learn More