<p>I have the following deployment running in a pod from my system:</p>
<pre><code>apiVersion: v1
kind: LimitRange
metadata:
  name: mem-limit-range
spec:
  limits:
  - default:
      memory: 1Gi
    defaultRequest:
      memory: 256Mi
    type: Container
</code></pre>
<p>Kubernetes is restarting this container some times, with this error code:</p>
<pre><code>Last State:     Terminated
      Reason:       OOMKilled
      Exit Code:    137
</code></pre>
<p>According to the system monitoring (Grafana), the container was only consuming ~500Mb of memory at the time the kill signal was sent by Kubernetes.</p>
<p>Also, the node where the the pod is running has a lot of available memory (it was using around 15% of its capacity at the time the container has been restarted).</p>
<p>So is there any possible reason for Kubernetes to restart this container? This already happened ~5-7 over the last week.</p>

Rodrigo Boos
<p>The <code>LimitRange</code> k8s object is used to &quot;Limit Range is a policy to constrain resource by Pod or Container in a namespace.&quot; So the objects in the namespace that the object <code>LimitRange</code> is created are consuming more than the limit specified in your <code>LimitRange</code> object. To test if this is true, remove the <code>LimitRange</code> temporarily to check the real usage of you ALL namespace resources, not just one pod. After that will be able to find the best limit config to fit the namespace.</p>
<p>In the <a href="https://v1-16.docs.kubernetes.io/docs/concepts/policy/limit-range/#:%7E:text=Limit%20Range%20is%20a%20policy,or%20Container%20in%20a%20namespace.&amp;text=A%20limit%20range%2C%20defined%20by,or%20Container%20in%20a%20namespace." rel="nofollow noreferrer">k8s docs</a>, you can find a good explanation and a lot of examples of how to restrict limits in your namespace.</p>
