Kubernetes Deep Dive Room

Sign Up Free or Log In to participate!

PVC claims PV

How the PVC claims the corresponding PV rightly? I see PVC YAML file doesn’t have PV details, so how this connection mechanism works?

1 Answers

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:

gke-pvc.yml

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:

gke-pv.yml

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.

Kevin Lambert

The video goes over this with a side-by-side comparison starting around the 5:35 mark.

RG

Use Labels in the definition of PV and then use the labels in PVC in Selector to be able to select a specific volume. This is going to be most useful at scale

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?