<p>I have a tiny Kubernetes cluster consisting of just two nodes running on <code>t3a.micro</code> AWS EC2 instances (to save money). </p>

<p>I have a small web app that I am trying to run in this cluster. I have a single <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="nofollow noreferrer"><code>Deployment</code></a> for this app. This deployment has <code>spec.replicas</code> set to 4.</p>

<p>When I run this <code>Deployment</code>, I noticed that Kubernetes scheduled 3 of its pods in one node and 1 pod in the other node.</p>

<p>Is it possible to force Kubernetes to schedule at most 2 pods of this <code>Deployment</code> per node? Having 3 instances in the same pod puts me dangerously close to running out of memory in these tiny EC2 instances.</p>

<p>Thanks!</p>

<p>The correct solution for this would be to set memory requests and limits correctly matching your steady state and burst RAM consumption levels on every pod, then the scheduler will do all this math for you.</p>

<p>But for the future and for others, there is a new feature which kind of allows this <a href="https://kubernetes.io/blog/2020/05/introducing-podtopologyspread/" rel="nofollow noreferrer">https://kubernetes.io/blog/2020/05/introducing-podtopologyspread/</a>. It's not an exact match, you can't put a global cap, rather you can require pods be evenly spaced over the cluster subject to maximum skew caps.</p>
