What is a persistent volume claims?

A persistent volume claim (PVC) is a storage request with specific access modes. The control loop in the master watches for new PVCs and finds a matching PV to bind it. If a PVC matches a PV, the volume will be bound as soon as possible. Otherwise, the claims will remain unbound for an indefinite period. Users may add a PV with the same size and type as their existing PV.

Reclaiming a persistent volume claim

You may have a volume bound to  persistent volume claims (PVC) that you want to delete. The reclaim policy is set to Retain, so the volume is not automatically deleted when you delete the claim. Instead, it retains the volume, which you can reuse for another PVC. You can reclaim a volume by editing the PVC object and setting the reclaim policy to Retain.

A persistent volume claim is a request to use the persistent storage resource. A PVC is similar to a Kubernetes Pod, requesting a storage space and an access type. This storage resource can be dynamic or static, such as the AWS EBS. Once you have created a Persistent Volume, you need to ensure it is configured to include the storage class and type you’d like.

Adding a persistent volume claim

A Persistent Volume Claim (PVC) is a storage request. These claims have specific access modes. The master watches for new PVCs finds matching PVs, and binds them to the master. The user is guaranteed to receive the minimum volume requested, which may exceed the size of the volume itself. If the volume exceeds the requested volume, it will remain unbound. The matching volumes are bound as soon as possible. For example, a 50Gi PV would not match a 100Gi PVC, but a 100Gi PV can be added to a cluster.

Pods use persistent volumes to store valuable data. These volumes have a lifecycle independent of the pods and remain available even if the pods are restarted or deleted. The storage space is shared across multiple applications running on a cluster. The application requests it by submitting a persistent volume claim. The administrator can create different storage classes with varying cost options and a separate storage backend.

Configuring a reclaim policy

To enable data persistence, you can configure the Reclaim Policy for Persistent Volume to RETAIN. Setting the Reclaim Policy to DELETE will result in unpredictable results. If you delete a PVC, the PV will be removed, and its associated data will no longer be available to your applications. This setting is recommended for ensuring consistent data persistence. However, you should note that the Reclaim Policy for Persistent Volume has been deprecated for OpenShift Container Platform 4 and should be replaced by Dynamic provisioning.

To configure a reclaim policy for persistent volumes, you must assign a storage class name to each volume. The name of the object is important. When creating a StorageClass object, administrators set the class parameters. Once created, they cannot be changed. Admins can also define the default StorageClass for PVCs. By setting the reclaim policy to ‘allow,’ the PVs are not deleted once they have been created.

Creating a reclaim policy for a persistent volume claim

Creating a reclaim policy for persistent volume claims is not as complex as you think. The process is similar to creating a new storage resource. You must first set the storage capacity for the persistent volume. Next, you must set the AllowVolumeExpansion field to true. If the reclaim policy is not set, you will be unable to expand the volume.

The first step is to create a PV and mark it as read-only. To do this, you need to modify the PersistentVolumeClaim capacity. Next, you must use the CSI driver specific to the persistent volume type. Once you’ve done this, the PV is available and can be used. Creating a reclaim policy for a persistent volume claim will prevent you from deleting the existing PV.

Creating a reclaim policy for an individual persistent volume claim is similar to creating a reclaim policy for a volume. The only difference is that persistent volume claims use the same conventions as volumes. You can specify the name of the PVC that is bound to your PV. You should also select the storage class name of the PVC. When generating the reclaim policy, make sure that the PV’s name matches the PVC’s name. If there are multiple PVCs, you can create a persistent volume claim to prevent the others from accessing the volume.