What is the difference between persistent volume (PV) and persistent volume claim (PVC) in simple terms?

47,404

Solution 1

PVC is a declaration of need for storage that can at some point become available / satisfied - as in bound to some actual PV.

It is a bit like the asynchronous programming concept of a promise. PVC promises that it will at some point "translate" into storage volume that your application will be able to use, and one of defined characteristics like class, size, and access mode (ROX, RWO, and RWX).

This is a way to abstract thinking about a particular storage implementation away from your pods/deployments. Your application in most cases does not need to declare "give me NFS storage from server X of size Y"; it is more like "I need persistent storage of default class and size Y".

With this, deployments on different clusters can choose to differently satisfy that need. One can link an EBS device, another can provision a GlusterFS, and your core manifests are still the same in both cases.

Furthermore, you can have Volume Claim Templates defined in your deployment, so that each pod gets a reflecting PVC created automatically (i.e., supporting infrastructure-agnostic storage definition for a group of scalable pods where each needs its own dedicated storage).

Solution 2

From the docs

PVs are resources in the cluster. PVCs are requests for those resources and also act as claim checks to the resource.

So a persistent volume (PV) is the "physical" volume on the host machine that stores your persistent data. A persistent volume claim (PVC) is a request for the platform to create a PV for you, and you attach PVs to your pods via a PVC.

Something akin to

Pod -> PVC -> PV -> Host machine

Solution 3

Short:
- Here you have the storage! PersistentVolume (PV)
- You get the storage if you really need it! PersistentVolumeClaim (PVC)

Solution 4

Short and Simple

Persistent Volume - Available storage let's say you have 100Gi

Persistent Volume Claim - You request from Persistent Volume, let's say you request 10Gi you'll get it but if you request 110Gi you won't get it.

Solution 5

A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by server/storage/cluster administrator or dynamically provisioned using Storage Classes. It is a resource in the cluster just like node.

A PersistentVolumeClaim (PVC) is a request for storage by a user which can be attained from PV. 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., they can be mounted ReadWriteOnce, ReadOnlyMany or ReadWriteMany.

Share:
47,404

Related videos on Youtube

smc
Author by

smc

Updated on July 08, 2022

Comments

  • smc
    smc almost 2 years

    What is the difference between persistent volume (PV) and persistent volume claim (PVC) in Kubernetes/ Openshift by referring to documentation?

    What is the difference between both in simple terms?

  • Pav K.
    Pav K. over 5 years
    Host machine could be any kind of Storage = [ NFS | cloud storage | storage providers | ... ]
  • Suhas Chikkanna
    Suhas Chikkanna over 5 years
    @will Gordon Request you to let me know, Where does storage class come into the picture in your answer.
  • Will Gordon
    Will Gordon over 5 years
    @SuhasChikkanna, StorageClasses (kubernetes.io/docs/concepts/storage/storage-classes) simply define the type of PVCs that a user can request.
  • Suhas Chikkanna
    Suhas Chikkanna over 5 years
    @WillGordon Yes, I now kind of see your picture as this, Please correct me if I am wrong :- Pod -> PVC -> PV -> (Storage Class, If applicable) -> Host machine. And also, for anyone else, this is good guide out there to know the difference between PV, PVC, Storage Class(portworx.com/basic-guide-kubernetes-storage).
  • Suhas Chikkanna
    Suhas Chikkanna over 5 years
    Anyone, looking for a clear difference/clarification between PV,PVC, Storage class can refer:- portworx.com/basic-guide-kubernetes-storage
  • Will Gordon
    Will Gordon over 5 years
    @SuhasChikkanna That seems about right, although I think the StorageClass would go between PVC and PV because it defines classes of PVs available to generate via PVC.
  • Ema.jar
    Ema.jar about 4 years
    Hi and welcome to Stack Overflow. Can you provide a more detailed explanation? It's fine to summarize your solution but please, try to be descriptive if you can :)
  • Vaviloff
    Vaviloff about 4 years
    A quote from the linked article: "Persistent Volume Claims represent the exclusive usage of a Persistent Volume by a particular Pod"
  • JayC
    JayC about 3 years
    is there a size cap?
  • Kirk Sefchik
    Kirk Sefchik about 3 years
    @Jesse it depends on how the kube provider configured their services. on a local machine obviously its limited to the size of your hdd
  • gyro
    gyro about 3 years
    "Persistent Volume Claims represent the exclusive usage of a Persistent Volume by a particular Pod" quote is not accurate. A pvc can be mounted in multiple pods.
  • Admin
    Admin over 2 years
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.