<p>I'm dealing with a certain service that causes (seemingly unresolvable) memory leaks from time to time. RAM memory inside of the container/pod grows high and stays that way. The pod soon becomes unusable and I would very much like to configure Kubernetes to mark those pods for termination and stop routing to them.</p>
<p>For example, if RAM reaches 80% inside the pod can I configure Kubernetes to shut down such pods?</p>
<p>Any links you can share about this would be great.</p>
<p>Thanks</p>

Gervasius Twinklewinkleson
<p>There are two different types of <a href="https://learnk8s.io/setting-cpu-memory-limits-requests" rel="nofollow noreferrer">resource configurations</a>  that can be set on each container of a pod.</p>
<p>They are <strong>requests</strong> and <strong>limits.</strong></p>
<p>Requests define the minimum amount of resources that containers need.</p>
<p>If you think that your app requires at least 256MB of memory to operate, this is the request value.</p>
<p>The application can use more than 256MB, but Kubernetes guarantees a minimum of 256MB to the container.</p>
<p>On the other hand, <strong>limits define the max amount of resources that the container can consume.</strong></p>
<p>Your application might require at least 256MB of memory, but you might want to be sure that it doesn't consume more than 1GB of memory.This is your <strong>limit.</strong></p>
<p>You can increase your request up to the limit range i.e, 1GB of memory. If the request is more than the limit, <a href="https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/" rel="nofollow noreferrer">Kubernetes</a> stops or throttles the pod.</p>
<p>For Example:</p>
<pre><code>resources:
  limits:
    memory: 1 GB
  requests:
    memory: 256 MB
</code></pre>
