<p>I am serving jupyter notebook through a Kubernetes cluster. And I've set <code>resources.limits</code> to prevent someone from draining all of the host servers memory. </p>

<p>While one problem is that the jupyter notebook kernels after crash and automatic restart they do not throw any OOM errors after the container exceeds the memory, which will make the user very confused. </p>

<p>So how can I make the jupyter notebook raise the OOM error when running with Kubernetes? </p>

<p>If you have only one specific pod, you can monitor the events/logs, <a href="https://stackoverflow.com/a/38270491/6309">as in here</a>:</p>

<pre><code>kubectl get events --watch 
kubectl logs -f podname
</code></pre>

<p>That being said, not <em>all</em> events in a <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/" rel="nofollow noreferrer">pod lifecycle</a> are properly reported, as shown in <a href="https://github.com/kubernetes/kubernetes/issues/38532#issuecomment-282154320" rel="nofollow noreferrer"><code>kubernetes/kubernetes</code> issue 38532</a> and the (abandoned) <a href="https://github.com/kubernetes/kubernetes/pull/45682" rel="nofollow noreferrer">PR 45682</a>.<br>
But you should still see  <code>OOMKilled:true</code> when <code>docker inspect</code>'ing the pod.</p>
