<p>I am debuggin a problem with pod eviction in Kubernetes.</p>
<p>It looks like it is related to a configuration in PHP FPM children processes quantity.</p>
<p>I assigned a minimum memory of 128 MB and Kubernetes is evicting my pod apparently when exceeds 10x that amount (<code>The node was low on resource: memory. Container phpfpm was using 1607600Ki, which exceeds its request of 128Mi.</code>)</p>
<p>How can I prevent this? I thought that requested resources is the minimum and that the pod can use whatever is available if there's no upper limit.</p>

JorgeeFG
<p>Requested memory is not &quot;the minimum&quot;, it is what it is called - the amount of memory <em>requested</em> by pod. When kubernetes schedules pod, it uses request as a guidance to choose a node which can accommodate this workload, but it doesn't guarantee that pod won't be killed if node is short on memory.</p>
<p>As per docs <a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#how-pods-with-resource-limits-are-run" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#how-pods-with-resource-limits-are-run</a></p>
<blockquote>
<p>if a container exceeds its memory request and the node that it runs on becomes short of memory overall, it is likely that the Pod the container belongs to will be evicted.</p>
</blockquote>
<p>If you want to guarantee a certain memory window for your pods - you should use <code>limits</code>, but in that case if your pod doesn't use most of this memory, it will be &quot;wasted&quot;</p>
<p>So to answer your question &quot;How can I prevent this?&quot;, you can:</p>
<ul>
<li>reconfigure your php-fpm in a way, that prevents it to use 10x memory (i.e. reduce workers count), and configure autoscaling. That way your overloaded pods won't be evicted, and kubernetes will schedule new pods in event of higher load</li>
<li>set memory limit to guarantee a certain amount of memory to your pods</li>
<li>Increase memory on your nodes</li>
<li>Use affinity to schedule your demanding pods on some dedicated nodes and other workloads on separate nodes</li>
</ul>
