Below is my scenario. I have an NFS setup and it will be used to create PV. and then use PVC to bind the volume. Now, Consider I want to bind particular PV/PVC together irrespective of where PVC will be created. As far as I tried I could not bind PV/PVC without bringing namespace into the picture. Since I use helm charts for deployment and the namespace can be anything (use can create/use any namespace) hence I do not want to restrict PV to look for PVC only in one namespace, rather bind to matching PVC from any namespace.
nfs-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-pv
spec:
capacity:
storage: 1Gi
volumeMode: Filesystem
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
storageClassName: nfs
claimRef:
name: nfs-pvc
namespace: default # This is something I wanna get rid off
nfs:
path: /apps/exports
server: <nfs-server-ip>
nfs-pvc.yaml #This one I should be able to create in any namespace and attach to the above PVC.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nfs-pvc
namespace: fhir
spec:
volumeName: nfs-pv
storageClassName: nfs
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
I have tried without giving the namespace option in PV, but it didn't work.
Any help on this would be much appreciated.
I think that is not possible because :
kubectl api-resources | grep 'pv\|pvc\|NAME'
NAME SHORTNAMES APIVERSION NAMESPACED KIND
persistentvolumeclaims pvc v1 true PersistentVolumeClaim
persistentvolumes pv v1 false PersistentVolume