Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shared PersistenceVolumeClaim(PVC) across namespaces

Is it possible to reference a PVC (in namespace-A) from namespace-B. Why I need that? I would like to allow the customer (private cloud) to point their volume through PVC, allowing them full control of the storage. At the Helm install time will ask for PVC information and will be used in the pod spec.

like image 467
Obidul Islam Avatar asked Jun 21 '18 00:06

Obidul Islam


People also ask

Can a pod use a PVC in a different namespace?

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.

Can PVC be shared?

TL;DR You can share PV and PVC within the same project/namespace for shared volumes (nfs, gluster, etc...), you can also access your shared volume from multiple project/namespaces but it will require project dedicated PV and PVCs, as a PV is bound to single project/namespace and PVC is project/namespace scoped.

Can multiple pods use same PVC?

Once a PV is bound to a PVC, that PV is essentially tied to the PVC's project and cannot be bound to by another PVC. There is a one-to-one mapping of PVs and PVCs. However, multiple pods in the same project can use the same PVC.

How can pods communicate across Kubernetes namespaces?

Namespaces are used to isolate resources within the control plane. For example if we were to deploy a pod in two different namespaces, an administrator running the “get pods” command may only see the pods in one of the namespaces. The pods could communicate with each other across namespaces however.


2 Answers

It looks impossible, just because PersistentVolumeClaim is a namespaced object. You can look detailed answer here: https://stackoverflow.com/a/35366775/9065705

like image 84
Konstantin Vustin Avatar answered Oct 21 '22 23:10

Konstantin Vustin


If you are using a ReadWriteMany-capable volume (like NFS/EFS), you can create multiple Persistent Volumes (PV) pointing to the same NFS volume, one for each namespace where you want to create a PVC. They can all use the same NFS volume at the same path, or specify different subPath to constrain them to certain directories.

like image 22
Eric McCormick Avatar answered Oct 21 '22 22:10

Eric McCormick