'Access file of a pod in Kubernetes

I have a cluster with multiple nodes and i also have created a persistent volume in order to have persistence of my data in a Pod. What i am actually looking for is the following:

Lets say that we have a pod, named pod1 that is connected with the Persistent Volume and in a specific directory we have some files. If i have another different pod, named pod2 which is in the same node with the pod1, that wants to copy a file from the directory of the pod1 which is connected with the PV.

Is there any right way to configure this?



Solution 1:[1]

What you need is a shared persistent volume mounted in both pods. You can achieve this in a couple of different ways:

  • Use a hostPath volume pointing to the same directory.
  • Use a volume type that supports RWX (read write many) access mode.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 whites11