<p>If I know for a fact during startup that my service will not work.. Is there anything I can return from one of the probes that will tell Kubernetes to act as if the pod is no longer usable and needs to be restarted?</p>

<p>Right now as far as I understand the only responses are 200-399 which will be handled as "success" and anything else which is regarded as a failure. Are there any other options?</p>

<p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/</a></p>

Shahar Prish
<p>If your process can determine that it's in an unsalvageable state, it doesn't need to wait for a probe to happen; it can just exit on its own, and Kubernetes will restart it.  How exactly to do this depends on your language but usually there is a function called <code>exit()</code>, or if your language has exceptions, throwing an exception and not catching it will generally terminate the program.</p>

<p>From a Kubernetes point of view this looks very similar to failing a liveness probe.  The container will terminate and restart; if it does that more than a couple of times, the cluster will start delaying the restarts, with the <code>CrashLoopBackOff</code> state.  Leaving yourself a hint by writing a diagnostic message before you exit is helpful, so that <code>kubectl logs</code> will explain why the process keeps exiting.</p>
