<p>I have <code>Kubernetes Deployment</code> with 10 pods.</p>
<p>And I have 10 directories path in my database table (path_table) as follow:</p>
<pre><code>path,id
c:\dir1, 1
c:\dir2, 2
...
c:\dir10, 10
</code></pre>
<p>I want to configure each pod to look on different path from DB.
Means - pod1 will monitor <code>c:\dir1</code>, pod2 will monitor <code>c:\dir2</code>,etc..</p>
<p>How can I make each pod start with different query from db to take it's path, example:</p>
<p>pod1 start with <code>select path from path_table where id=1</code></p>
<p>pod2 start with <code>select path from path_table where id=2</code></p>
<p>...</p>

Mar Teen
<p>As mentioned in the comments, I don't think it is possible with <code>Deployment</code> as the pods in a <code>Deployment</code> are independent replicas of the same application with no state.</p>
<p>You might want to look at <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer"><code>StatefulSets</code></a> where each pod has a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#ordinal-index" rel="nofollow noreferrer">unique name</a> that can be used to work on a specific directory as you require.</p>
<p>You can pass the pod name as the environment variable to the pods which has a unique id in case of <code>Statefulset</code>:</p>
<pre><code>env:
      - name: MY_POD_NAME
        valueFrom:
          fieldRef:
            fieldPath: metadata.name
</code></pre>
<p>So, if you have ten replicas of a <code>Statefulset</code> with name <code>myapp</code> then the pods will have the names as <code>myapp-0</code>, <code>myapp-1</code> and so on.</p>
<p>You can then internally use these names to work on specific directories based on the env value of <code>MY_POD_NAME</code>.</p>
