Pv and pvc in another namespace- why still binds?

i created a pv in default namespace

Next i created a new pvc in another namespace named green-tiger.

pvc yaml:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-pvc
  namespace: green-tiger
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi

and pv.yaml:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: my-pv
spec:
  capacity:
    storage: 2Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/Volumes/Data"

as u can see there is no selector that pvc can bind, but somehow right after pvc created, the status is ‘bound’.
pv and pvc are properly bound. why? since there is no matchLabels or selector field specified anywhere. why does it bind immediately?

Hi @Erjan-G ,
Please check this lecture again.

I think you are missing the other properties such as accessModes, storageClass etc.

Regards,

  1. point one is that, PV and PVC comes under the cluster scope resources not name spaced. Not sure if there is any way to restrict this.

  2. here, the config that allowed your PVC to be bind with PV in another name space.
    capacity:
    storage: 2Gi
    accessModes:

    • ReadWriteOnce