Ping pods of a statefulset via DNS

9/4/2018

I am setting up VerneMQ (a MQTT broker) in a cluster configuration. Therefore I am launching 4 replicas in a stateful set. Apparently VerneMQ wants to communicate with the other brokers in a cluster via DNS like this:

echo "Will join an existing Kubernetes cluster with discovery node at 
${kube_pod_name}.${VERNEMQ_KUBERNETES_SUBDOMAIN}.${DOCKER_VERNEMQ_KUBERNETES_NAMESPACE}.svc.cluster.local"

Unfortunately the logs indicate that this doesn't work:

14:05:56.741 [info] Application vmq_server started on node 'VerneMQ@broker-vernemq-0.broker-vernemq.messaging.svc.cluster.local'

broker-vernemq-0 is the pod's name and broker-vernemq is the name of the statefulset. The service is configured as LoadBalancer.

The problem:

I connected to the pod broker-vernemq-1 via terminal and executed ping broker-vernemq-0 and I wondered that it is not able to resolve this hostname:

ping: unknown host broker-vernemq-0

I was under the impression that this is supposed to work?

-- kentor
kube-dns
kubernetes

1 Answer

9/4/2018

The service must be headless for kube-dns to service domain names like that. See https://stackoverflow.com/a/46638059

-- Lev Kuznetsov
Source: StackOverflow