<p>I want to know if it's possible that multiple PersistentVolumeClaims bind to the same <a href="https://kubernetes.io/docs/concepts/storage/volumes/#local" rel="nofollow noreferrer">local persistent volume</a>.</p>

<p>My use-case if the following: I want to build a Daemon Set that will write some data (the same data actually) on each node on my cluster (on the node's local disk). Then, any other pod that is scheduled on any node should be able to read that data. Basically a kind of write-once-read-many policy at the node level.</p>

<p>I know that I can do that using the <strong>hostPath</strong> type of volume, but it's a bit hard to manage so I found out that local-storage would be a better approach.</p>

<p>My wish would be the following:</p>

<ul>
<li>Create the local Persistent Volume (named pv) with <strong>ReadWriteOnce</strong> and <strong>ReadOnlyMany</strong> access modes</li>
<li>Create the first persistent volume claim (pvc1) with <strong>ReadWriteOnce</strong> access mode and use it in the DaemonSet that writes the data in the volume. So <strong>pvc1</strong> should bind to <strong>pv</strong></li>
<li>Create the second persistent volume claim (pvc2) with <strong>ReadOnlyMany</strong> access mode that is used in any other pod that reads that data (so <strong>pvc2</strong> should also bind to <strong>pv</strong>)</li>
</ul>

<p>Is this possible?</p>

<p>I read that if a PVC is bounded to a PV, then that PV is "locked", meaning that no other PVC can bind to it. Is this really how it works? If seems a bit limiting for that kind of scenarios, where we have write-once-read-many operations.</p>

<p>Thanks!</p>

<p>DaemonSets and PVCs for RWO volume types do not mix well because all the DaemonSets will share the same PVC. And for local volumes, that would result in only one replica to be scheduled since it restricts all Pods using that PVC to only get scheduled to one node. </p>

<p>You could potentially solve this by using a StatefulSet, which supports <code>volumeClaimTemplates</code> that creates a PVC per replica, and have it scale to the number of nodes in the cluster. However, your user pods would then need to know and pick a specific PVC to use, rather than use whatever is on that node.</p>

<p>I think your use case would be better addressed by writing a <a href="https://kubernetes-csi.github.io/docs/" rel="nofollow noreferrer">CSI driver</a>. It has a DaemonSet component, which on driver startup can initialize the data. Then when it implements <code>NodePublishVolume</code> (aka mount into the pod), it can bind-mount the data directory into the pod's container. You can make this volume type RWX, and you probably don't need to implement any of the controller routines for provisioning or attaching.</p>
