I've searched the internet for tutorials / guides on how one can share volumes across multiple pods - and only found a few articles explaining how to share volumes among containers inside same pod. Then I came across this SO question, but the accepted answer wasn't clear to me. Let's assume the following scenario:
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-one
spec:
selector:
matchLabels:
app: one
template:
metadata:
labels:
app: one
spec:
containers:
- name: one
image: some_username/container_one:latest
volumeMounts:
- name: volume-one
mountPath: /one
volumes:
- name: volume-one
persistentVolumeClaim:
claimName: awesome-pvc
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-two
spec:
selector:
matchLabels:
app: two
template:
metadata:
labels:
app: two
spec:
containers:
- name: two
image: some_username/container_two:latest
volumeMounts:
- name: volume-two
mountPath: /two
volumes:
- name: volume-two
persistentVolumeClaim:
claimName: awesome-pvc
So awesome-pvc
is shared between 2 pods in the above example. So how can one "access" /two
from first pod? In the simplest word: how can one copy files from /two
to /one
?