<p>I have an application deployed in Kubernetes.  I am using the Istio service mesh.  One of my services needs to be restarted when a particular error occurs.  Is this something that can be achieved using Istio?</p>
<p>I don't want to use a cronjob.  Also, making the application restart itself seems like an anti-pattern.</p>
<p>The application is a node js app with fastify.</p>

Sid
<p>Istio is a network connection tool. I was creating this answer when <a href="https://stackoverflow.com/users/10008173/david-maze">David Maze</a> made a very correct mention in a comment:</p>
<blockquote>
<p>Istio is totally unrelated to this. Another approach could be to use a Kubernetes <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/" rel="nofollow noreferrer">liveness probe</a> if the cluster can detect the pod is unreachable; but if you're going to add a liveness hook to your code, <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#when-should-you-use-a-liveness-probe" rel="nofollow noreferrer">the Kubernetes documentation also endorses just crashing</a> on unrecoverable failure.</p>
</blockquote>
<p>The <a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/" rel="nofollow noreferrer">kubelet</a> uses liveness probes to know when to restart a container. For example, liveness probes could catch a deadlock, where an application is running, but unable to make progress. Restarting a container in such a state can help to make the application more available despite bugs.</p>
<p>See also:</p>
<ul>
<li><a href="https://cloud.google.com/blog/products/containers-kubernetes/kubernetes-best-practices-setting-up-health-checks-with-readiness-and-liveness-probes" rel="nofollow noreferrer">health checks on the cloud - GCP example</a></li>
<li><a href="https://github.com/oracle/weblogic-kubernetes-operator/issues/1395" rel="nofollow noreferrer">creating custom rediness/liveness probe</a></li>
<li><a href="https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/domain-lifecycle/liveness-readiness-probe-customization/" rel="nofollow noreferrer">customization liveness probe</a></li>
</ul>
