What is a Persistent Volume Claim?

A persistent volume claim (PVC) is a local storage device mounted on a node. It is also known as a local disk. A PVC should be created using a valid DNS subdomain name. This article explains the creation and reclaiming of persistent volumes in Kubernetes. The definition of a persistent volume differs from that of a container volume.


Creating a persistent volume claim

Creating a persistent volume claim (PVC) in Kubernetes is a common way to use storage resources for your applications. The process involves configuring a persistent volume claim (PVC) for your application pod and binding it to persistent storage. The PVC belongs to your application pod and can only be used by the developers running in that pod. It is important to note that PVCs are not shared with other developers in the cluster.

In Kubernetes, volumes are abstractions of application resources, such as disk space or memory. They provide a storage directory for containers running in a POD. A persistent volume is a part of physical storage that remains available for a given duration, allowing the containers to continue running even if the POD is restarted. The PVC must be mounted as a volume in the workload and include minimum resources.


Reclaiming a persistent volume

Multiple cluster nodes can use a persistent volume claim (PVC) storage resource. A PVC can be used for various purposes, including storing data for database applications and other applications that run frequently. In Kubernetes, any pod can claim a PV, regardless of its namespace or underlying storage provider. This feature is available through the Kubernetes API.

When a cluster creates a PVC, it declares how the resource is used and what kind of access it has. For example, if multiple pods use a persistent volume, the cluster will try to match its requests with the available storage. To do this, the pod must specify the storage parameters, such as the amount of data it needs and what type of access it needs. Not all persistent volume types support mount options.


Container volumes vs. persistent volumes

When creating pods, you need to determine which of the two storage types. Container volumes are the default, so the most common way to use them is to mount them into your pods. Persistent volume claims (PVC) are also the most common, but they can be useful when you want to use more storage than what is available with your containers. In addition, persistent volumes are also backed by storage classes, which are used to interact with different types of storage.

As a result, it’s possible to use both types of storage. The difference between PVCs and containers is how they handle the reclaiming and allocation of storage space. The former requires that you specify the size of the nodes. The latter has the advantage of being able to scale, as you don’t need to worry about scaling and replacing storage resources if one fails.


Creating a reclaim policy for a persistent volume

A persistent volume claim can be consumed and created by applying the Retain Policy. To consume a persistent volume, the AllowVolumeExpansion field must be true. When the PVC object is edited, the volume will be expanded. However, no new PVC is created to satisfy a claim. Instead, the existing volume is resized.

The persistent volume can be deleted or retained depending on the reclaim policy. The reclaim policy of a PVC object is defined in the storage class and can be deleted or retained. StorageClass objects default to delete, while manually created persistent volumes have a reclaim policy assigned when they are created. Once the PVC was deleted, the storage was bound to be available for other PVCs.