PVC to PV Binding
A PVC asks for storage, and out of several free volumes in the cluster only one ends up bound to it, while a second, identical claim stays Pending. Who picks that one volume, and by what rules does it choose?
Play the animation 6 steps, animated, plays on a computer or a tablet
PVC to PV Binding, step by step
-
A PersistentVolumeClaim is a request, not storage. It states only what the workload needs: at least 5Gi, ReadWriteOnce access, and the fast StorageClass. Under the default Immediate binding mode, the Pod cannot be scheduled while the claim it references is still unbound.
Play from step 1 -
The binding controller watches every claim in the cluster. This one is new and still unbound, so the controller reads what the claim asks for: capacity, access mode and StorageClass.
Play from step 2 -
The controller checks every Available volume in one sweep. PV a01 is only 2Gi, which is under what the claim asks for, and PV b22 belongs to the slow class rather than fast. PV x73a is the only one that fits the claim, so it is the candidate. Had several fit, the smallest would win.
Play from step 3 -
The controller writes the binding to the volume first. PV x73a gets a claimRef pointing at data-claim and turns Bound, so no other claim can take it. Only then does the claim get a volumeName pointing back at PV x73a and turn Bound as well, and each object now names the other.
Play from step 4 -
Only now can the Pod run. It is scheduled onto a Node, and Kubelet there resolves the claim to its bound volume and mounts that volume for the Pod. The container starts with the volume at /data. The Pod holds the claim, and the volume behind the claim stores the bytes.
Play from step 5 -
Binding is one to one, and once made it is exclusive. A second claim asking for exactly the same thing cannot have PV x73a, which already carries a claimRef. These volumes were pre-created by an administrator and the class has no dynamic provisioner, so nothing builds a new one. The controller records a ProvisioningFailed event, and the claim stays Pending until a matching volume appears.
Play from step 6