<p>I'm trying to setup a zookeeper cluster (3 replicas) but each host can't connect to another and I really don't know where's the problem.
It's creating 3 pods successfully with names like </p>

<pre><code>zookeeper-0.zookeeper-internal.default.svc.cluster.local
zookeeper-1.zookeeper-internal.default.svc.cluster.local
zookeeper-2.zookeeper-internal.default.svc.cluster.local
</code></pre>

<p>but when connected to one of them and trying to connect to the open port  it returns the Unknown host message:</p>

<pre><code>zookeeper@zookeeper-0:/opt$ nc -z zookeeper-1.zookeeper-internal.default.svc.cluster.local 2181
zookeeper-1.zookeeper-internal.default.svc.cluster.local: forward host lookup failed: Unknown host
</code></pre>

<p><a href="https://gist.github.com/ranierimazili/822fafb0440064c893064201df9e4fba" rel="nofollow noreferrer">My YAML file is here</a></p>

<p>I really appreciate any help.</p>

Ranieri Mazili
<p>Did you create a headless service as you had mentioned in your yaml - <code>serviceName: zookeeper-internal</code> ?</p>

<p>You need to create this service (update the port) to access the <code>zookeeper-0.zookeeper-internal.default.svc.cluster.local</code></p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  labels:
    app: zookeeper-cluster-dev
    name: zookeeper
  name: zookeeper-internal
spec:
  ports:
  - name: zookeeper-port
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    name: zookeeper
  clusterIP: None
  type: ClusterIP
</code></pre>

<hr>

<p>Service is required. But it does not expose anything outside the cluster. It is only within cluster. Any pods can access this service within the cluster. So you can not access it from your browser unless you expose it via <code>NodePort</code> / <code>LoadBalancer</code> / <code>Ingress</code>! </p>
