<p>On my Kubernetes Setup, I have 2 pods - A (via deployment) and B(via DS).
Pod B is somehow dependent on Pod A being fully started through. I would now like to set an HTTP Liveness-Probe in Pods B, to restart POD B if health check via POD A fails. Restarting works fine if I put the External IP of my POD A's service in the host. The issue is in resolving DNS name in the host.</p>
<p>It works if I set it like this:</p>
<pre class="lang-yaml prettyprint-override"><code>livenessProbe:
  httpGet:
    host: &lt;POD_A_SERVICE_EXTERNAL_IP_HERE&gt;
    path: /health
    port: 8000
</code></pre>
<p>Fails if I set it like this:</p>
<pre class="lang-yaml prettyprint-override"><code>livenessProbe:
  httpGet:
    host: auth
    path: /health
    port: 8000
</code></pre>
<p>Failed with following error message:</p>
<blockquote>
<pre class="lang-sh prettyprint-override"><code>Liveness probe failed: Get http://auth:8000/health: dial tcp: lookup auth on 8.8.8.8:53: no such host
</code></pre>
</blockquote>
<p>ref: <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>
<p>Is the following line on the above page true for HTTP Probes as well?
&quot;you can not use a service name in the host parameter since the kubelet is unable to resolve it.&quot;</p>

Abhi Gadroo
<p>Correct 👍, DNS doesn't work for liveness probes, the kubelet network space cannot basically resolve any in-cluster DNS.</p>
<p>You can consider putting both of your services in a single pod as sidecars. This way they would share the same address space if one container fails then the whole pod is restarted.</p>
<p>Another option is to create an <a href="https://kubernetes.io/docs/concepts/extend-kubernetes/operator/" rel="nofollow noreferrer">operator</a> 🔧 for your pods/application and basically have it check the liveness through the in-cluster DNS for both pods separately and restart the pods through the Kubernetes API.</p>
<p>You can also just create your own script in a pod that just calls <a href="https://curl.haxx.se/" rel="nofollow noreferrer"><code>curl</code></a> to check for a <code>200 OK</code> and <code>kubectl</code> to restart your pod if you get something else.</p>
<p>Note that for the 2 options above you need to make sure that Coredns is stable and solid otherwise your health checks might fail to make your services have potential downtime.</p>
<p>✌️☮️</p>
