Chapter 6. Expanding persistent volumes
To increase available storage capacity, expand persistent volumes in MicroShift. You can resize existing volumes to accommodate growing application data requirements without recreating storage resources.
6.1. Expanding CSI volumes Copy linkLink copied to clipboard!
You can use the Container Storage Interface (CSI) to expand storage volumes after they have already been created.
Shrinking persistent volumes (PVs) is not supported.
Prerequisites
The underlying CSI driver supports resize.
For information about which CSI drivers support resizing, see under the Additional resources section "CSI drivers supported by Red Hat build of MicroShift".
- Dynamic provisioning is used.
The controlling
StorageClassobject hasallowVolumeExpansionset totrue.For more information, see section Enabling volume expansion support.
Procedure
-
For the persistent volume claim (PVC), set
.spec.resources.requests.storageto the desired new size.
Verification
-
To confirm that the resize is finished, look at the
status.conditionsfield of the PVC . Red Hat build of MicroShift adds theResizingcondition to the PVC during expansion, which is removed after expansion completes.
6.3. Expanding local volumes Copy linkLink copied to clipboard!
To expand your Local Storage Operator (LSO) storage capacity and meet growing data needs, update the storage request in your persistent volume (PV) and persistent volume claim (PVC). This increases capacity for existing volumes without recreating them.
Procedure
- Expand the underlying devices. Ensure that appropriate capacity is available on these devices.
-
Update the corresponding PV objects to match the new device sizes by editing the
.spec.capacityfield of the PV. -
For the storage class that is used for binding the PVC to PV, set the
allowVolumeExpansionfield totrue. -
For the PVC, set
.spec.resources.requests.storageto match the new size.
Result
Kubelet should automatically expand the underlying file system on the volume, if necessary, and update the status field of the PVC to reflect the new size.
6.4. Expanding persistent volume claims (PVCs) with a file system Copy linkLink copied to clipboard!
To expand your storage capacity and meet growing data needs, you can resize existing volumes without recreating them.
Expanding persistent volume claims (PVCs) based on volume types that need file system resizing, such as Google Cloud Platform (GCP) persistent disk (PD), AWS Elastic Block Storage (EBS), and Cinder, is a two-step process. First, expand the volume objects in the cloud provider. Second, expand the file system on the node.
Expanding the file system on the node only happens when a new pod is started with the volume.
Prerequisites
The controlling storage class has the
allowVolumeExpansionfield set totrue.For more information, see section Enabling volume expansion support.
Procedure
Edit the PVC and request a new size by editing
spec.resources.requests. For example, the following expands theebsPVC to 8 Gi:Example PVC YAML file
kind: PersistentVolumeClaim apiVersion: v1 metadata: name: ebs spec: storageClass: "storageClassWithFlagSet" accessModes: - ReadWriteOnce resources: requests: storage: 8GiWhere updating
spec.resources.requeststo a larger amount expands the PVC.
Verification
After the cloud provider object has finished resizing, the PVC is set to FileSystemResizePending.
Check the condition by running the following command:
$ oc describe pvc <pvc_name>
Next steps
When the cloud provider object has finished resizing, the PersistentVolume object reflects the newly requested size in PersistentVolume.Spec.Capacity. You can now create or recreate a new pod from the PVC to finish the file system resizing. After the pod is running, the newly requested size is available and the FileSystemResizePending condition is removed from the PVC.
6.5. Recovering from failure when expanding volumes Copy linkLink copied to clipboard!
If a resize request fails or remains in a pending state, you can try again by entering a different resize value in .spec.resources.requests.storage for the persistent volume claim (PVC). The new value must be larger than the original volume size.
If entering another smaller resize value in .spec.resources.requests.storage for the PVC does not work, use the following procedure to recover.
Procedure
-
Mark the persistent volume (PV) that is bound to the PVC with the
Retainreclaim policy. Change thepersistentVolumeReclaimPolicyfield toRetain. - Delete the PVC.
-
Manually edit the PV and delete the
claimRefentry from the PV specification to ensure that the newly created PVC can bind to the PV markedRetain. This marks the PV asAvailable. - Recreate the PVC in a smaller size, or a size that can be allocated by the underlying storage provider.
-
Set the
volumeNamefield of the PVC to the name of the PV. This binds the PVC to the provisioned PV only. - Restore the reclaim policy on the PV.