<p>I have 3 nodes in a k8s cluster and I need exactly 2 pods to be scheduled in each node, so I would end up having 3 nodes with 2 pods each (6 replicas).</p>

<p>I found that k8s have <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#inter-pod-affinity-and-anti-affinity-beta-feature" rel="nofollow noreferrer">Pod Affinity/Anti-Affinity</a> feature and that seems to be the correct way of doing.</p>

<p>My problem is: I want to run 2 pods per node but I often use <code>kubectl apply</code> to upgrade my docker image version, and in this case k8s should've be able to schedule 2 new images in each node before terminating the old ones - will the newer images be scheduled if I use Pod Affinity/Anti-Affinity to allow only 2 pods per node?</p>

<p>How can I do this in my deployment configuration? I cannot get it to work.</p>

stefanobaldo
<p>I believe it is part of kubelet's setting, so you would have to look into kubelet's <code>--max-pods</code> flag, depending on what your cluster configuration is.
The following links could be useful:</p>

<p><a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/#kubelet" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/#kubelet</a></p>

<p>and </p>

<p><a href="https://kubernetes.io/docs/tasks/administer-cluster/reconfigure-kubelet/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/administer-cluster/reconfigure-kubelet/</a></p>
