Chapter 7. Expanding persistent volumes
7.1. Enabling volume expansion support Copy linkLink copied to clipboard!
Before you can expand persistent volumes, the StorageClass
object must have the allowVolumeExpansion
field set to true
.
Procedure
Edit the
StorageClass
object and add theallowVolumeExpansion
attribute by running the following command:oc edit storageclass <storage_class_name>
$ oc edit storageclass <storage_class_name>
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specifies the name of the storage class.
The following example demonstrates adding this line at the bottom of the storage class configuration.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Setting this attribute to
true
allows PVCs to be expanded after creation.
7.2. 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. See "CSI drivers supported by Red Hat OpenShift Service on AWS" in the "Additional resources" section.
- Dynamic provisioning is used.
-
The controlling
StorageClass
object hasallowVolumeExpansion
set totrue
. For more information, see "Enabling volume expansion support."
Procedure
-
For the persistent volume claim (PVC), set
.spec.resources.requests.storage
to the desired new size. -
Watch the
status.conditions
field of the PVC to see if the resize has completed. Red Hat OpenShift Service on AWS adds theResizing
condition to the PVC during expansion, which is removed after expansion completes.
7.3. Expanding local volumes Copy linkLink copied to clipboard!
You can manually expand persistent volumes (PVs) and persistent volume claims (PVCs) created by using the local storage operator (LSO).
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.capacity
field of the PV. -
For the storage class that is used for binding the PVC to PVet, set
allowVolumeExpansion:true
. -
For the PVC, set
.spec.resources.requests.storage
to match the new size.
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.
7.4. Expanding persistent volume claims (PVCs) with a file system Copy linkLink copied to clipboard!
Expanding PVCs based on volume types that need file system resizing, such as AWS Elastic Block Store EBS (EBS) 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
StorageClass
object must haveallowVolumeExpansion
set totrue
.
Procedure
Edit the PVC and request a new size by editing
spec.resources.requests
. For example, the following expands theebs
PVC to 8 Gi:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Updating
spec.resources.requests
to a larger amount expands the PVC.
After the cloud provider object has finished resizing, the PVC is set to
FileSystemResizePending
. Check the condition by entering the following command:oc describe pvc <pvc_name>
$ oc describe pvc <pvc_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
When the cloud provider object has finished resizing, the
PersistentVolume
object reflects the newly requested size inPersistentVolume.Spec.Capacity
. At this point, you can create or recreate a new pod from the PVC to finish the file system resizing. Once the pod is running, the newly requested size is available and theFileSystemResizePending
condition is removed from the PVC.
7.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 you are still having issues, use the following procedure to recover.
Procedure
If entering another smaller resize value in .spec.resources.requests.storage
for the PVC does not work, do the following:
-
Mark the persistent volume (PV) that is bound to the PVC with the
Retain
reclaim policy. ChangepersistentVolumeReclaimPolicy
toRetain
. - Delete the PVC.
-
Manually edit the PV and delete the
claimRef
entry from the PV specs to ensure that the newly created PVC can bind to the PV markedRetain
. This marks the PV asAvailable
. - Re-create the PVC in a smaller size, or a size that can be allocated by the underlying storage provider.
-
Set the
volumeName
field 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.