Accessing persistent volumes in pods across differernt namespaces

If we have persistent volume in a cluster which we want to access that PV in pods present in different namespaces, how can we achieve that ?
Suppose we have two namespaces ‘ns1’ and ‘ns2’ in a cluster and if the pod within ns1 has a claim requesting a specific storage volume and then the cluster dynamically provisions a volume for that PVC. So pod will access that PV and some data is stored within that PV.So PV is bound to PVC in namespace ‘ns1’. So is there any way to access that PV within a pod which is in namespace ‘ns2’.

TLDR; No

A PVC is a namespaced resource, Pods on different namespaces can’t share the same PVC.
Pods on different namespaces would need to use two different PVC resources.
Since you mentioned dynamic provisioning, the PVs are dynamically created and allocated to a single PVC, creating a second PVC will allocate new and different PV

A PV can only be bound to a single PVC,

1 Like

Is it possible in the case of NFS/EFS storage, if I create another PVC in another namespace ‘ns2’, and mount the same directory which is mounted for PVC in namespace ‘ns1’? So will PVC in namespace ‘ns2’ be able to access all the data within that directory?

OpenShift supports NFS…so, I suspect NFS is supported on Kubernetes (upstream).
https://docs.openshift.com/container-platform/3.11/install_config/persistent_storage/persistent_storage_nfs.html

yeah NFS is supported in Kubernetes but will I be able to access data of PV in pods across different namespaces with the approach I mentioned above?

@Amey24 yes you should be able to access the same data/files on nfs if you have 2 PVs pointing to the same directory on nfs, and both PVCs can access the same data. I will be surprised if you can’t.

Also, there are CSI drivers that are based on S3 storage (cloud object storage), and it would be the same concept 2 PVs pointing to the same bucket