A volume is considered to be offline when it is not attached to a node or pod. Both types of clusters, Supervisor Clusters and Tanzu Kubernetes clusters, support offline volume expansion.
Procedure
- Create a persistent volume claim (PVC) with a storage class.
- Define a PVC using the following YAML manifest as an example.
In the example, the size of the requested storage is 1 Gi.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: example-block-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: example-block-sc
- Apply the PVC to the Kubernetes cluster.
kubectl apply -f example-block-pvc.yaml
- Patch the PVC to increase its size.
If the PVC is not attached to a node or being used by a pod, use the following command to patch the PVC. In this example, the requested storage increase is 2 Gi.
kubectl patch pvc example-block-pvc -p '{"spec": {"resources": {"requests": {"storage": "2Gi"}}}}'
This action triggers an expansion in the volume associated with the PVC.
- Verify that the size of the volume has increased.
kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-9e9a325d-ee1c-11e9-a223-005056ad1fc1 2Gi RWO Delete Bound default/example-block-pvc example-block-sc 6m44s
Note: The size of the PVC remains unchanged until the PVC is used by a pod.
The following example shows that the PVC size hasn't changed. If you describe the PVC, you can see the
FilesystemResizePending
condition applied on the PVC.
kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
example-block-pvc Bound pvc-9e9a325d-ee1c-11e9-a223-005056ad1fc1 1Gi RWO example-block-sc 6m57s
- Create a pod to use the PVC.
When the PVC is used by the pod, the filesystem is expanded.
- Verify that the size of the PVC has been modified.
kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
example-block-pvc Bound pvc-24114458-9753-428e-9c90-9f568cb25788 2Gi RWO example-block-sc 2m12s
The
FilesystemResizePending
condition has been removed from the PVC. Volume expansion is complete.
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.