<p>I reload my process running as a Kubernetes Deployment by exiting 0. Sometimes the restarts may be frequent depending on external factors. It does not affect my application as the restarts are intentional and graceful shutdown happens.</p>
<p>Problem is Kubernetes sees this as a problem and puts my pod into Crashloop. Please suggest how to disable Crashloop in pods.</p>
<p>I am using restart and Kubernetes Deployment as a feature.</p>

Alok Kumar Singh
<p>Posting this as <code>Community Wiki</code> as good point was mention in comment section by @Matt.</p>
<p>Unfortunately, at this moment changing <code>CrashLoopBackOff</code> as this is <code>Work as Intended</code> behavior.
As pointed in <a href="https://sysdig.com/blog/debug-kubernetes-crashloopbackoff/" rel="nofollow noreferrer">Sysdig documentation</a> about <code>CrashLoopBackOff</code></p>
<blockquote>
<p>A CrashloopBackOff means that you have a pod starting, crashing, starting again, and then crashing again.</p>
</blockquote>
<p>There is an open thread on <a href="https://github.com/kubernetes/kubernetes/issues/57291" rel="nofollow noreferrer">Github</a> for some <code>CrashLoopBackoff</code> changes, which might be useful in the future with scenarios like this, however it's open since <code>Dec 2017</code>.</p>
<p><code>Restart Policy</code> as default is set to <code>Always</code>, so chaning it won't help.</p>
<blockquote>
<p>The default value is <code>Always</code> and the <code>restartPolicy</code> only refers to restarts of the containers by the kubelet on the same node (so the restart count will reset if the pod is rescheduled in a different node). Failed containers that are restarted by the kubelet are restarted with an exponential back-off delay (10s, 20s, 40s …) capped at five minutes, and is reset after ten minutes of successful execution.</p>
</blockquote>
<p>Good explanation about <code>Network Policy</code> differences can be found in <a href="https://stackoverflow.com/questions/40530946/what-is-the-difference-between-always-and-on-failure-for-kubernetes-restart-poli">this Stackoverflow thread</a>.</p>
<blockquote>
<p><strong>Always</strong> means that the container will be restarted even if it exited with a zero exit code (i.e. successfully). This is useful when you don't care why the container exited, you just want to make sure that it is always running (e.g. a web server). This is the default.</p>
</blockquote>
<blockquote>
<p><strong>Failure</strong> means that the container will only be restarted if it exited with a non-zero exit code (i.e. something went wrong). This is useful when you want accomplish a certain task with the pod, and ensure that it completes successfully - if it doesn't it will be restarted until it does.</p>
</blockquote>
<p><strong>As workaround</strong></p>
<p>You can think about using <a href="https://kubernetes.io/docs/concepts/workloads/controllers/job/" rel="nofollow noreferrer">Kubernetes jobs</a>, as per @Pythonista answer and depends on your needs you can also use <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/" rel="nofollow noreferrer">Kubernetes CronJobs</a>.</p>
