0

I am wondering what does "capacity" mean for Kubernetes persistent volume claim. Does that mean Kubernetes will schedule a pod with the volume you specified (e.g. 20 GB) on your cluster and that 20 GB space will be isolated or does it automatically scale down if you didn't fully use the 20 GB.

franco mo
  • 11
  • 1

1 Answers1

2

From the docs:

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.

So, a PVC is not an actual storage but a request for the storage. A Persistent Volume (PV) is the actual storage:

A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes.

A PVC resource gets bound to the actual PV resource if there is a matching PV available. The physical storage can then be used by the pods by using the reference to the PVC in the pods spec persistentVolumeClaim field under volumes.

I am wondering what does "capacity" mean for Kubernetes persistent volume claim.

The PVC resource do not have a capacity field but has a storage field which implies that this PVC resource will bound to a PV object if the matching capacity on the PV object has at least the amount of storage requested by the PVC object if provisioned statically.

PVC can also be configured to allow dynamic provision which implies the actual storage will be provisioned as part of the PVC creation if there is not a matching PV already in the cluster.

Does that mean Kubernetes will schedule a pod with the volume you specified (e.g. 20 GB) on your cluster and that 20 GB space will be isolated or does it automatically scale down if you didn't fully use the 20 GB.

If you have configured dynamic provisioning for the cluster and create a PVC object then a matching PV object is created internally and the PVC gets bound to the same. A pod needs to reference the PVC object to actually use it. Further, storage resources do not get resized automatically based on the actual consumption. Once created they will be persisted until deleted explicitly and they have the lifecycle independent of the pods.

Krishna Chaurasia
  • 8,924
  • 6
  • 22
  • 35