<p>Is there a way to restart pods automatically after some time or when they reach some memory limit?</p>

<p>I want achieve the same behavior as gunicorn(or any mainstream process manager does)</p>

<h1>Memory limit</h1>
<p>If you set a limit for the memory on a container in the podTemplate, this pod will be restarted if it uses more than specified memory.</p>
<pre><code>resources:
  limits:
    memory: 128Mi
</code></pre>
<p>See <a href="https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/" rel="nofollow noreferrer">Managing Compute Resources for Containers
</a> for documentation</p>
<h1>Time limit</h1>
<p>This can be done in many different ways, internally by calling <code>exit(1)</code> or stop responding on a configured <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/" rel="nofollow noreferrer">livenessProbe</a>. Or externally, e.g. by configuring a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/" rel="nofollow noreferrer">CronJob</a>.</p>
