Auto bound PVC to PV

8/16/2019

Good day!

If you do not explicitly specify volumeName when creating PVC in Openshift, then to which PV will the PVC be bounded?

I think that PVC can be tied to any PV in the "Available" status if Storage size matches claim.

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc_name
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 10G
  storageClassName: ""
  volumeName: 

Tell me how this process works? Thanks.

-- mapu
kubernetes
openshift
persistent-volume-claims
persistent-volumes

1 Answer

8/22/2019

In Kubernetes, since for the storageClassName: "" dynamic provisioning does not work, Kubernetes will look through the list of existing PVs for the smallest matching one that has no class, until the DefaultStorageClass admission plugin is turned on.

If a selector or access modes are provided, logical AND is applied to the requirements. Hence the only a PV with no class and with the requested mode and labels will be chosen.

With the DefaultStorageClass set, its value is then used to dynamically provision storage for PVCs that do not require any specific class.

As for the PVC sample in question, ccshih has provided nearly the exact answer: with no DefaultStorageClass enabled and configured, the smallest available PV of size 10G (10e9 bytes ~ 9.3 GiB) or larger with no class and ReadWriteOnce access mode will be bound.

Please see Lifecycle of a volume and claim

The provisioning logic is described here: Controller workflow for provisioning volumes

-- mebius99
Source: StackOverflow