<p>I have a <code>DaemonSet</code> that creates flink task manager pods, one per each node.</p>

<h2>Nodes</h2>

<p>Say I have two nodes</p>

<ul>
<li>node-A</li>
<li>node-B</li>
</ul>

<h2>Pods</h2>

<p>the daemonSet would create </p>

<ul>
<li>pod-A on node-A</li>
<li>pod-B on node-B</li>
</ul>

<h2>Persistent Volume Claim</h2>

<ul>
<li>I am on AKS and want to use <code>azure-disk</code> for Persistent Storage</li>
<li>According to the docs : [<a href="https://learn.microsoft.com/en-us/azure/aks/azure-disks-dynamic-pv" rel="noreferrer">https://learn.microsoft.com/en-us/azure/aks/azure-disks-dynamic-pv</a> ]

<ul>
<li>an azure disk can be associated on to single node</li>
</ul></li>
</ul>

<p>say I create</p>

<ul>
<li>pvc-A for pv-A attached to node-A</li>
<li>pvc-B for pv-B attached to node-B</li>
</ul>

<h2>Question</h2>

<p>How can I associate <strong>pod-A</strong> on <strong>node-A</strong> to use <strong>pcv-A</strong> ?</p>

<h1>UPDATE:</h1>

<p>After <em>much</em> googling, i stumbled upon that it might be better/cleaner to use a StatefulSet instead. This does mean that you won't get the features available to you via DaemonSet like one pod per node.</p>

<blockquote>
  <p><a href="https://medium.com/@zhimin.wen/persistent-volume-claim-for-statefulset-8050e396cc51" rel="noreferrer">https://medium.com/@zhimin.wen/persistent-volume-claim-for-statefulset-8050e396cc51</a></p>
</blockquote>

frictionlesspulley
<p>If you use a persistentVolumeClaim in your daemonset definition, and the persistentVolumeClaim is satisfied with PV with the type of <code>hostPath</code>, your daemon pods will read and write to the local path defined by <code>hostPath</code>. This behavior will help you separate the storage using one PVC.</p>

<p>This might not directly apply to your situation but I hope this helps whoever searching for something like a "volumeClaimTemplate for DaemonSet" in the future.</p>

<p>Using the same example as cookiedough (thank you!)</p>

<pre><code>apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: x
  namespace: x
  labels:
    k8s-app: x
spec:
  selector:
    matchLabels:
      name: x
  template:
    metadata:
      labels:
        name: x
    spec:
      ...
      containers:
      - name: x
        ...
        volumeMounts:
        - name: volume
          mountPath: /var/log
      volumes:
      - name: volume
        persistentVolumeClaim:
          claimName: my-pvc
</code></pre>

<p>And that PVC is bound to a PV (Note that there is only one PVC and one PV!)</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  creationTimestamp: null
  labels:
    type: local
  name: mem
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 1Gi
  hostPath:
    path: /tmp/mem
    type: Directory
  storageClassName: standard
status: {}
</code></pre>

<p>Your daemon pods will actually use <code>/tmp/mem</code> on each node. (There's at most 1 daemon pod on each node so that's fine.)</p>
