<p>I have 3 deployments, <code>a-depl</code>, <code>b-depl</code>, <code>c-depl</code>. Now each of these 3 deployments has a db deployment: <code>a-db-depl</code>, <code>b-db-depl</code>, <code>c-db-depl</code>.
Now I want to persist each of these dbs. Do I need to create a single PV for all or a PV for each of the deployments?</p>

<p>I know that PV &lt;-> PVC is 1-to-1 relation. But I dont know about Depl &lt;-> PV.
Can someone please help?</p>

<p>As of now, I have no clue, so I am using a single PV for all of the dp deployments</p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: mongo-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: "/mnt/data/mongo"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mongo-pv-claim
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 2Gi
</code></pre>

potatoxchip
<p>At a time one PV can be bound to only one PVC. So for each of your PVC you need to create a corresponding PV. To automate PV creation you can create a <code>StorageClass</code> and refer that <code>StorageClass</code> in your PVC. <code>StorageClass</code> can dynamically provision a PV for each PVC.</p>

<p>Whether multiple deployments can use the same PVC or PV depends on <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes" rel="noreferrer"><code>accessModes</code></a> of the PVC or PV. </p>

<p><code>ReadOnlyMany</code> - the volume can be mounted read-only by many nodes</p>

<p><code>ReadWriteMany</code>- the volume can be mounted as read-write by many nodes</p>

<p><code>ReadWriteOnce</code> - the volume can be mounted as read-write by a single node</p>
