Chapter 4. Expanding persistent volumes
4.1. Enabling volume expansion support
Before you can expand persistent volumes, the StorageClass must have the
allowVolumeExpansion field set to
Edit the StorageClass and add the
allowVolumeExpansionattribute. The following example demonstrates adding this line at the bottom of the StorageClass’s configuration.
apiVersion: storage.k8s.io/v1 kind: StorageClass ... parameters: type: gp2 reclaimPolicy: Delete allowVolumeExpansion: true 1
- Setting this attribute to
trueallows PVCs to be expanded after creation.
4.2. Expanding CSI volumes
You can use the Container Storage Interface (CSI) to expand storage volumes after they have already been created.
OpenShift Container Platform supports CSI volume expansion by default. However, a specific CSI driver is required.
OpenShift Container Platform does not ship with any CSI drivers. It is recommended to use the CSI drivers provided by community or storage vendors. Follow the installation instructions provided by the CSI driver.
OpenShift Container Platform 4.3 supports version 1.1.0 of the CSI specification.
Expanding CSI volumes is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
For more information about the support scope of Red Hat Technology Preview features, see https://access.redhat.com/support/offerings/techpreview/.
4.3. Expanding FlexVolume with a supported driver
When using FlexVolume to connect to your backend storage system, you can expand persistent storage volumes after they have already been created. This is done by manually updating the persistent volume claim (PVC) in OpenShift Container Platform.
FlexVolume allows expansion if the driver is set with
true. The FlexVolume can be expanded on Pod restart.
Similar to other volume types, FlexVolume volumes can also be expanded when in use by a Pod.
- The underlying volume driver supports resize.
The driver is set with the
- Dynamic provisioning is used.
The controlling StorageClass has
To use resizing in the FlexVolume plugin, you must implement the
ExpandableVolumePlugininterface using these methods:
true, updates the capacity directly. If
false, calls the
ExpandFSmethod to finish the filesystem resize.
ExpandFSto resize filesystem after physical volume expansion is done. The volume driver can also perform physical volume resize together with filesystem resize.
Because OpenShift Container Platform does not support installation of FlexVolume plugins on master nodes, it does not support control-plane expansion of FlexVolume.
4.4. Expanding Persistent Volume Claims (PVCs) with a file system
Expanding PVCs based on volume types that need file system resizing, such as GCE PD, EBS, and Cinder, is a two-step process. This process involves expanding volume objects in the cloud provider, and then expanding the file system on the actual node.
Expanding the file system on the node only happens when a new pod is started with the volume.
The controlling StorageClass must have
Edit the PVC and request a new size by editing
spec.resources.requests. For example, the following expands the
ebsPVC to 8 Gi.
kind: PersistentVolumeClaim apiVersion: v1 metadata: name: ebs spec: storageClass: "storageClassWithFlagSet" accessModes: - ReadWriteOnce resources: requests: storage: 8Gi 1
spec.resources.requeststo a larger amount will expand the PVC.
Once the cloud provider object has finished resizing, the PVC is set to
FileSystemResizePending. The following command is used to check the condition:
$ oc describe pvc <pvc_name>
When the cloud provider object has finished resizing, the persistent volume object reflects the newly requested size in
PersistentVolume.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 the
FileSystemResizePendingcondition is removed from the PVC.
4.5. Recovering from Failure when Expanding Volumes
If expanding underlying storage fails, the OpenShift Container Platform administrator can manually recover the Persistent Volume Claim (PVC) state and cancel the resize requests. Otherwise, the resize requests are continuously retried by the controller without administrator intervention.
Mark the persistent volume (PV) that is bound to the PVC with the
Retainreclaim policy. This can be done by editing the PV and changing
- Delete the PVC. This will be recreated later.
To ensure that the newly created PVC can bind to the PV marked
Retain, manually edit the PV and delete the
claimRefentry from the PV specs. This marks the PV as
- Re-create the PVC in a smaller size, or a size that can be allocated by the underlying storage provider.
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.