educative.io

If PVC selects PV on its own, how it gurantees that it will be attached to same PV

Hi,

I understand that PVC will look out for match and if found a PV it will get bounded.

It seems okay if it is for first time, however how kubernetes gurantees and PVC bound to same PV everytime, because state is stored on to that and on failure of any component it should reconnect.


Course: https://www.educative.io/collection/10370001/5920988434792448
Lesson: https://www.educative.io/collection/page/10370001/5920988434792448/6598236833841152

Hello @Vishal_Jha

Kubernetes doesn’t offer a strict guarantee that a PersistentVolumeClaim (PVC) will be bound to the same PersistentVolume (PV) every time it’s created or when it’s reattached after, for instance, a failure or recreation of components. However, it provides mechanisms that enhance the probability of maintaining consistency:
Storage Class: If you want to bind a PVC to a specific type or class of storage, you should use a StorageClass. StorageClasses allow administrators to define different classes of storage with different features, and when a PVC is created with a specific StorageClass, it gets bound to a suitable PV based on the criteria defined in that class. This helps in maintaining some level of predictability in PVC-to-PV binding.
Binding Process: When a PVC is created, Kubernetes attempts to bind it to an available PV that fulfills its requirements. If a specific PV is no longer available or fails for some reason, Kubernetes will try to bind it to another suitable PV that meets the PVC’s criteria.

While Kubernetes does its best to maintain consistency and binding between PVCs and PVs, it doesn’t assure that a PVC will always be bound to the same PV, especially in cases where the original PV is unavailable due to failure or deletion. Therefore, it’s crucial to design applications to handle potential changes in the underlying storage.

To ensure resilience in scenarios where PVs may change due to failure or recreation, applications should be designed to handle the possibility of data loss or changes in the underlying storage.

I hope this will help.
Happy Learning