An online volume is a volume that is available on a node or pod. As a DevOps engineer, you can expand an online persistent block volume. Both types of clusters, Supervisor Clusters and Tanzu Kubernetes clusters, support online volume expansion.

Prerequisites

Make sure to upgrade your vSphere environment to an appropriate version that supports online volume expansion. See Volume Expansion in vSphere with Tanzu.

Procedure

  1. Find the persistent volume claim to resize.
    $ kubectl get pv,pvc,pod
    NAME                                                        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM               STORAGECLASS   REASON   AGE
    persistentvolume/pvc-5cd51b05-245a-4610-8af4-f07e77fdc984   1Gi        RWO            Delete           Bound       default/block-pvc   block-sc                4m56s
     
    NAME                              STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
    persistentvolumeclaim/block-pvc   Bound    pvc-5cd51b05-245a-4610-8af4-f07e77fdc984   1Gi        RWO            block-sc       5m3s
     
    NAME            READY   STATUS    RESTARTS   AGE
    pod/block-pod   1/1     Running   0          26s

    Note that the size of storage the volume uses is 1 Gi.

  2. Patch the PVC to increase its size.
    For example, increase the size to 2 Gi.
    $ kubectl patch pvc block-pvc -p '{"spec": {"resources": {"requests": {"storage": "2Gi"}}}}'
    persistentvolumeclaim/block-pvc edited
    This action triggers an expansion in the volume associated with the PVC.
  3. Verify that the size of both PVC and PV has increased.
    $ kubectl get pvc,pv,pod
    NAME                              STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
    persistentvolumeclaim/block-pvc   Bound    pvc-5cd51b05-245a-4610-8af4-f07e77fdc984   2Gi        RWO            block-sc       6m18s
     
    NAME                                                        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM               STORAGECLASS   REASON   AGE
    persistentvolume/pvc-5cd51b05-245a-4610-8af4-f07e77fdc984   2Gi        RWO            Delete           Bound       default/block-pvc   block-sc                6m11s
     
    NAME            READY   STATUS    RESTARTS   AGE
    pod/block-pod   1/1     Running   0          101s

What to do next

A vSphere administrator can see the new volume size in the vSphere Client. See Monitor Persistent Volumes in the vSphere Client.