<p>I currently configure my Nginx Pod <strong>readinessProbe</strong> to monitor Redis port 6379, and I configure my redis-pod behind the redis-service (ClusterIP).</p>

<p>So my idea is <strong>to monitor Redis port though redis-service using DNS</strong> instead of IP address.</p>

<p>When I use <code>readinessProbe.host: redis-service.default.svc.cluster.local</code> the Nginx-pod is not running. When I describe the Nginx-pod <code>$ kubectl describe pods nginx</code>,  I found below error in Events section:  </p>

<p><code>Readiness probe failed: dial tcp: lookup redis-service.default.svc.cluster.local: no such host</code></p>

<p>It only works if I use ClusterIP instead of DNS. </p>

<p>Please help me figure out how to use DNS instead of ClusterIP.</p>

<p>My Pod file:</p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: nginx
  name: nginx
spec:
  containers:
  - image: nginx
    name: nginx
    livenessProbe:
      httpGet:
        path: /
        port: 80
    readinessProbe:
      tcpSocket:
        host: redis-service.default.svc.cluster.local
        port: 6379
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
</code></pre>

<p>Thanks.</p>

DagaReiN
<p>I figured out how to do it.</p>

<p>Instead of using tcpSocket, just use exec.
Exec your tcpCheck script inside the container to check the service:port availability.</p>

<p><strong>Use your init-container to share the script with the main container.</strong></p>

<p>Thanks.</p>
