linuxkubernetesstorage

Persistent volume and claims in kubernetes workspace


I have been working in k8's workspace in for like 6 months now and always wonder why do we need a Persistent Volume(PV) and Persistent Volume claim(PVC)? Can anyone please make this concept clear to me?


Solution

  • The separation of PV and PVCs enable a division of responsibilities in Kubernetes cluster administration and resource management.

    The PVs are objects that the cluster administrator(s) would create, and they abstract away underlying storage resources to expose an unified view to the user (ie. this is the "volume" you can use with this much space). They only care about exposing the storage resource to the cluster, and not who or how it's going to be used. Quoting the documentation:

    A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator. It is a resource in the cluster just like a node is a cluster resource. PVs are volume plugins like Volumes, but have a lifecycle independent of any individual pod that uses the PV. This API object captures the details of the implementation of the storage, be that NFS, iSCSI, or a cloud-provider-specific storage system.

    The PVC, on the other hand, can be used by the cluster users (ie. those who are deploying and maintaining applications) to dynamically request and release storage blocks without worrying about the underlying infrastructure. They don't necessarily have to care about from where the storage comes from or it's actually managed. Quoting the documentation

    A PersistentVolumeClaim (PVC) is a request for storage by a user. It is similar to a pod. Pods consume node resources and PVCs consume PV resources. Pods can request specific levels of resources (CPU and Memory). Claims can request specific size and access modes (e.g., can be mounted once read/write or many times read-only).

    In dynamically provisioned deployments, Kubernetes takes on the role of the PV management. Users simply request a PVC, and Kubernetes will provision the PV and bind the PVC to PV making the storage provisioning process transparent to the cluster users.