<p>In my kubernetes cluster, have 1 master and 3 nodes.</p>
<p>Will have a deployment/daemonset running on each node and will need storage.</p>
<p>Thought about local storage due performance issues with gluster, since will have a lot of files (small/big).</p>
<p>Is there a way of assigning automatically the pvc which has the pv in the node where the pod has been allocated?</p>
<p>Thanks</p>

<blockquote>
<p>Is there a way of assigning automatically the pvc which has the pv in
the node where the pod has been allocated?</p>
</blockquote>
<p>It depends what you exactly mean by <em>&quot;assigning automatically the pvc&quot;</em> but I believe that <a href="https://kubernetes.io/docs/concepts/storage/volumes/#local" rel="nofollow noreferrer">local volume</a> should meet your requirements. <code>PVC</code> or many different <code>PVCs</code></p>
<p>It's biggest advantagle over <code>hostPath</code> is no need for scheduling Pods manually to specific nodes as node affinity is defined on the <code>PersistentVolume</code>:</p>
<blockquote>
<p>Compared to <code>hostPath</code> volumes, local volumes can be used in a durable
and portable manner without manually scheduling Pods to nodes, as the
system is aware of the volume's node constraints by looking at the
node affinity on the PersistentVolume.</p>
</blockquote>
<p>You just need to define a local storage class, local <code>PV</code> and <code>PVC</code>, which then you can use in <code>volumeClaimTemplates</code> like in the following fragment of a <code>Statefulset</code> specification:</p>
<pre><code>...
  volumeClaimTemplates:
  - metadata:
      name: local-vol
    spec:
      accessModes: [ &quot;ReadWriteOnce&quot; ]
      storageClassName: &quot;local-storage&quot;
      resources:
        requests:
          storage: 368Gi
</code></pre>
<p>All your <code>Pods</code> will be automatically scheduled to appropriate nodes as the node affinity is already defined in <code>PersistentVolume</code> and specific <code>PersistentVolumeClaim</code> is bind to such <code>PV</code>. It's important to remember that <code>PV:PVC</code> is always <code>1:1</code> binding, while one <code>PVC</code> can be used by many different <code>Pods</code>. When it comes to local volume, if <code>Pods</code> use a single common <code>PVC</code>, they all will be scheduled on the same node on which the claimed <code>PV</code> is located.</p>
