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

11

147

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?

Camilia answered 23/2, 2018 at 20:52 Comment(0)
C
106

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).

Crisis answered 23/2, 2018 at 21:56 Comment(3)
Anyone, looking for a clear difference/clarification between PV,PVC, Storage class can refer:- portworx.com/basic-guide-kubernetes-storageSceptic
A quote from the linked article: "Persistent Volume Claims represent the exclusive usage of a Persistent Volume by a particular Pod"Regnant
"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.Kermitkermy
C
126

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
Crat answered 23/2, 2018 at 21:28 Comment(5)
Host machine could be any kind of Storage = [ NFS | cloud storage | storage providers | ... ]Bizerte
@will Gordon Request you to let me know, Where does storage class come into the picture in your answer.Sceptic
@SuhasChikkanna, StorageClasses (kubernetes.io/docs/concepts/storage/storage-classes) simply define the type of PVCs that a user can request.Crat
@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).Sceptic
@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.Crat
C
106

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).

Crisis answered 23/2, 2018 at 21:56 Comment(3)
Anyone, looking for a clear difference/clarification between PV,PVC, Storage class can refer:- portworx.com/basic-guide-kubernetes-storageSceptic
A quote from the linked article: "Persistent Volume Claims represent the exclusive usage of a Persistent Volume by a particular Pod"Regnant
"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.Kermitkermy
R
24

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

Reverse answered 6/2, 2020 at 16:2 Comment(1)
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 :)Determine
F
15
  1. A PersistentVolume (PV) is a piece of storage in the cluster or central storage let's say 100GB.

  2. A PersistentVolumeClaim (PVC) is a request for storage by a user for the application to use 10GB.

In real life scenario, PV is whole cake and PVC is piece of cake (But you can have a whole cake if there are no other people to eat (just like if there are no other application to use you can use whole PV )).

Frontier answered 28/3, 2020 at 16:29 Comment(0)
P
10

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.

Phage answered 21/7, 2020 at 11:2 Comment(0)
C
9

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.

Concord answered 21/7, 2020 at 9:30 Comment(2)
is there a size cap?Tunic
@Jesse it depends on how the kube provider configured their services. on a local machine obviously its limited to the size of your hddInsider
C
4

A Persistent Volume Claim is telling you what options you have access to in a particular cluster and they got this circular at this store called Smart Tech with some ads about your configuration options, those ads are the Persistent Volume Claim.

Inside your config file you write out the different Persistent Volume Claims that you are going to have inside your cluster, kind of like your wish list to Santa, but of course you are going to go take that to the sales guy at Smart Tech when you are done.

So you write a config file that says there should a 600gb hard drive option available to all your clusters and a 1TB hard drive option as well.

When you choose one of these options of the Persistent Volume Claim you go and request that Kubernetes (the sales guy) goes and gets that option for you, the option you have chosen, Kubernetes has to look through these instances of storage options in the stock room that are readily available. These instances of hard drives can be used right away and they are considered statically provisioned because they are created ahead of time.

On the other hand, there is dynamically provisioned options that were created on the fly, when you asked Kubernetes the sales guy, so kind of like just-in-time production, it got created when you immediately asked for it.

So the Persistent Volume Claim is the stores advertisement of options and whichever one you choose Kubernetes will go get it, either one in storage or create one on the fly.

The Persistent Volume is the actual product or options that you get back from Kubernetes that you asked for. If Kubernetes does not have what you asked for it will try to create it on the fly for you.

So the PVC is what Smart Tech is advertising they have to offer to your cluster which Kubernetes the sales guy will get for you and the PV is the actual finished product delivered to you.

Comnenus answered 29/5, 2019 at 5:15 Comment(0)
S
4

PersistentVolume(PV) and PersistentVolumeClaim(PVC) are the resources APIs provided by the Kubernetes. PV is a piece of storage which supposed to preallocated by an admin. And PVC is a request for a piece of storage by a user.

Smallman answered 3/3, 2020 at 7:10 Comment(0)
H
3

Persistent Volume — low level representation of a storage volume. Persistent Volume Claim — binding between a Pod and Persistent Volume. Storage Class — allows for dynamic provisioning of Persistent Volumes.

Hildebrandt answered 14/10, 2021 at 5:4 Comment(1)
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.Dolmen
O
2

You can find some common when comparing PV and PVC with node and pods. PV like a node, which defines the storage. PVC like pods that requires the resources (Mem, CPU) and get them in case the node has the resources to allocate, which in this case it's a storage.

Oudh answered 25/3, 2020 at 8:37 Comment(0)
S
0

Difference between Persistent Volume (PV) and Persistent Volume Claim (PVC):

  1. PVCs are namespaced.
  2. PVCs are utilized by pods inside a node.

whereas

  1. PVs are not namespaced.
  2. PVs are set up by the Kubernetes administrators.
Snake answered 30/8, 2023 at 8:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.