<p>I want to limit the maximum number of restarts for a pod. I have restartPolicy as always and I don't want to change it to Never,but want to limit the number of restarts.Is it possible to do so somehow ?</p>

<blockquote>
<p>I just don't want the service to restart like 900 or 1000 times. In few restarts, it should stop trying...</p>
</blockquote>
<p>Say, you want to do something (by the program runs inside the pod) which requires a couple of retries but you also don't want it to retry an infinite number of times.</p>
<p>In such a case, I will recommend you to handle it from inside the program instead of handling it from the pod's restart.</p>
<p>Wrap your task inside a retries loop with a timeout/maxRetries:</p>
<pre><code>Algo:

 - Retries until timeout/maxRetires:
   - Do your job
 - end loop
</code></pre>
<p><strong>NB:</strong> If you want your pod to terminate after completing the task, use k8s <code>Job</code> instead of Pod.</p>
