How the PVC claims the corresponding PV rightly? I see PVC YAML file doesn’t have PV details, so how this connection mechanism works?
PVCs look for a PV that satisfies the requirements of its .spec section and will select one that fits. In this lesson, the PVC .spec sections lists the following requirements:
spec: accessModes: - ReadWriteOnce storageClassName: ssd resources: requests: storage: 20Gi
In order for a PV to be selected by this PVC, it would need to satisfy each of the listed requirements:
– The access mode must be ReadWriteOnce.
– The storage class must be SSD.
– The storage capacity must be at least 20GB.
The PV from this lesson lists the following in its .spec section:
spec: accessModes: - ReadWriteOnce storageClassName: ssd capacity: storage: 20Gi persistentVolumeReclaimPolicy: Retain gcePersistentDisk: pdName: uber-disk
We can see that this PV matches all of the requirements listed in the PVC:
– The access mode is ReadWriteOnce.
– The storage class is SSD.
– The capacity is 20GB.
Because it matches the requirements, the PVC will select this PV.