We have two pods in Kubernetes that for sake of conversation we'll call pod1 and pod2. I created pv1 and pvc1 on pod 1 and it's working fine. In my opinion, the documentation is not clear enough about this scenario or I couldn't find the right wiki. How can I access pv1 and pvc1 from pod2?
Sharing a persistent volume between pods in Kubernetes
26.1k Views Asked by AR1 At
2
There are 2 best solutions below
1

Accessing the same PV on multiple node is not that easy as it looks. First of all, based on your your use case, you need a supporting filesystem underneath for creating this shared storage. An EFS/NFS/GlusterFS should be ideal and kubernetes volume plugin support most of these. Additionally you need to have PVC with the right access mode Eg : ReadWriteMany, in case you are looking for a multi-write architecture. Again, in a micro service world, you should try to avoid such use cases or find better alternatives to make your design scalable, stateless to a possible extend. https://12factor.net/ emphasize most of these principles.
From the k8s documentation:
Meaning that in the scenario pictured in the question, if PodA_deployment.yaml creates a volume claim:
then PodB will be able to mount the pv making a claim like the following:
in PodB_deployment.yaml. While it's clear once and it makes sense once you get to understand it, the documentation could explain it better.