Welcome to the Linux Foundation Forum!

Exercise: 3.2.19 how pvc knows about pv

Options

Hello all,

I’m following the lfd259 and have a question regarding the exercise 3.2.19

There I’m creating the the generated svc, pvc and deployment from the yaml file and some steps before 3.2.11 I created the the volumes (pv)
Where is the connection between pvc and pv, how kubernetes knows that those pvc’s should be bound to the already created pv’s in the previous step (3.2.11)?

I would expect to have some kind of selector or name reference, but I don’t find anything

Thank you very much for your help

Best regards
Joao Martins

Comments

  • chrispokorni
    chrispokorni Posts: 2,208
    Options

    Hi Joao,

    By default, the PVCs are searching for PVs based on the properties included in the PVC yaml manifest. Once a PVC finds a PV that matches its properties, the PVC binds itself to the PV. When there are multiple PVs with matching properties, then the PVC binds itself randomly to one of the PVs.

    In multi-PV and multi-PVC scenarios, we may use labels and selectors to ensure that PVC1 binds to PV1, and PVC2 binds to PV2... Otherwise, the bind is random.

    Regards,
    -Chris

  • serewicz
    serewicz Posts: 1,000
    Options

    Hello,

    As Chris mentions the selection process for the PVC is probably best done using labels and selectors, or names. Otherwise the PVC will first be constrained by storageClass, then access mode, then will select the first PV which has at least the requested capacity. As JSON does not present data in a consistent order, it could be any volume available. A PVC request for 1G could bind to any PV of 1G or larger, including a 200TB volume, even if a 1G volume was available but not first evaluated.

    As a result, as Chris mentioned, it can be difficult to determine which PV will be bound to a particular PVC unless declared using selectors and labels, or names.

    Regards,

Categories

Upcoming Training