<p>Whenever I do a Kubernetes deployment with some sort of configuration error, the pod ends up in CrashLoopBackOff, constantly restarting the (totally broken) pod. What I would like is for any sort of errors during a deployment to immediately fail the deployment, rather than just blindly retrying until the deployment times out.</p>

Luke Schlather
<p>Deploy with <code>restartPolicy: never</code> and then use <a href="https://kubernetes.io/docs/concepts/cluster-administration/manage-deployment/#kubectl-patch" rel="nofollow noreferrer">kubectl patch</a> to modify the restart policy of that deployment.</p>

<p>To avoid continuous restart attempt of failing pod there is one open <a href="https://github.com/kubernetes/kubernetes/issues/49466" rel="nofollow noreferrer">issue</a>.</p>

<p>Also there is one open <a href="https://github.com/kubernetes/kubernetes/pull/79334" rel="nofollow noreferrer">pull request</a> to add this feature which is about to get merged, where you will have ability to specify max retries for restart policy OnFailure.</p>

<p>Till this feature get merged and released, <code>kubectl patch</code> seems to be the only way.</p>
