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 pc1 from pod2?
From the k8s documentation:
A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator. It is a resource in the cluster just like a node is a cluster resource. PVs are volume plugins like Volumes, but have a lifecycle independent of any individual pod that uses the PV. This API object captures the details of the implementation of the storage, be that NFS, iSCSI, or a cloud-provider-specific storage system.
A PersistentVolumeClaim (PVC) is a request for storage by a user. It is similar to a pod. Pods consume node resources and PVCs consume PV resources. Pods can request specific levels of resources (CPU and Memory). Claims can request specific size and access modes (e.g., can be mounted once read/write or many times read-only).
Meaning that in the scenario pictured in the question, if PodA_deployment.yaml creates a volume claim:
volumeMounts:
- name: myapp-data-pv-1
mountPath: /home/myappdata/mystuff
then PodB will be able to mount the pv making a claim like the following:
volumes:
- name: myapp-data-pv-1
persistentVolumeClaim:
claimName: myapp-data-pvc-1
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.