# Set up elasticsearch to use pod names during discovery instead of Pod IP

**URL:** <https://discuss.elastic.co/t/set-up-elasticsearch-to-use-pod-names-during-discovery-instead-of-pod-ip/104272>\
**Category:** Elasticsearch\
**Created:** [October 17, 2017, 4:02pm UTC](https://discuss.elastic.co/t/set-up-elasticsearch-to-use-pod-names-during-discovery-instead-of-pod-ip/104272 "2017-10-17T16:02:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![akpt](https://avatars.discourse-cdn.com/v4/letter/a/90db22/32.png) [@akpt](https://discuss.elastic.co/u/akpt)\
**Post date:** [October 17, 2017, 4:02pm UTC](https://discuss.elastic.co/t/set-up-elasticsearch-to-use-pod-names-during-discovery-instead-of-pod-ip/104272/1 "2017-10-17T16:02:37Z")

</div>

In my minikube cluster, my elasticsearch pods have the config:

```
cluster.name: elasticsearch-logs
node.name: ${HOSTNAME}
node.master: true
node.data: true
network.host: _site_
transport.tcp.port: 9300
http.port: 9200 
http.enabled: true
http.cors.enabled: true
bootstrap.memory_lock: false
xpack.security.enabled: false
discovery.zen.minimum_master_nodes: 2
discovery.zen.ping_timeout: 10s
discovery.zen.ping.unicast.hosts: ["es-0:9300", "es-1:9300", "es-2:9300"]

```

However when I use my pod names I get errors connecting the pods/setting up the 3 master nodes

```
[2017-10-17T15:56:35,102][INFO][o.e.d.DiscoveryModule] [es-0] using discovery type [zen]
[2017-10-17T15:56:37,953][INFO][o.e.n.Node] [es-0] initialized
[2017-10-17T15:56:37,953][INFO][o.e.n.Node] [es-0] starting ...
[2017-10-17T15:56:38,899][INFO][o.e.t.TransportService] [es-0] publish_address {172.17.0.3:9300}, bound_addresses {172.17.0.3:9300}
[2017-10-17T15:56:38,980][INFO][o.e.b.BootstrapChecks] [es-0] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[2017-10-17T15:56:44,112][WARN][o.e.d.z.UnicastZenPing] [es-0] timed out after [5s] resolving host [es-1:9300]
[2017-10-17T15:56:44,114][WARN][o.e.d.z.UnicastZenPing] [es-0] timed out after [5s] resolving host [es-2:9300]
[2017-10-17T15:56:54,129][WARN][o.e.d.z.ZenDiscovery] [es-0] not enough master nodes discovered during pinging (found [[Candidate{node={es-0}{H8EUqY6ARq2tkcGXWXH8sQ}{GTwfoPpCSfyZVdu9MRc_ng}{172.17.0.3}{172.17.0.3:9300}{ml.max_open_jobs=10, ml.enabled=true}, clusterStateVersion=-1}]], but needed [2]), pinging again
[2017-10-17T15:56:59,130][WARN][o.e.d.z.UnicastZenPing] [es-0] timed out after [5s] resolving host [es-1:9300]
[2017-10-17T15:56:59,131][WARN][o.e.d.z.UnicastZenPing] [es-0] timed out after [5s] resolving host [es-2:9300]
[2017-10-17T15:57:09,090][WARN][o.e.n.Node] [es-0] timed out while waiting for initial discovery state - timeout: 30s
[2017-10-17T15:57:09,127][INFO][o.e.h.n.Netty4HttpServerTransport] [es-0] publish_address {172.17.0.3:9200}, bound_addresses {172.17.0.3:9200}
[2017-10-17T15:57:09,127][INFO][o.e.n.Node] [es-0] started
[2017-10-17T15:57:09,132][WARN][o.e.d.z.ZenDiscovery] [es-0] not enough master nodes discovered during pinging (found [[Candidate{node={es-0}{H8EUqY6ARq2tkcGXWXH8sQ}{GTwfoPpCSfyZVdu9MRc_ng}{172.17.0.3}{172.17.0.3:9300}{ml.max_open_jobs=10, ml.enabled=true}, clusterStateVersion=-1}]], but needed [2]), pinging again
[2017-10-17T15:57:09,135][WARN][o.e.d.z.UnicastZenPing] [es-0] failed to resolve host [es-1:9300]
java.net.UnknownHostException: es-1
	at java.net.InetAddress.getAllByName0(InetAddress.java:1280) ~[?:1.8.0_141]
	at java.net.InetAddress.getAllByName(InetAddress.java:1192) ~[?:1.8.0_141]
	at java.net.InetAddress.getAllByName(InetAddress.java:1126) ~[?:1.8.0_141]
	at org.elasticsearch.transport.TcpTransport.parse(TcpTransport.java:908) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.transport.TcpTransport.addressesFromString(TcpTransport.java:863) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.transport.TransportService.addressesFromString(TransportService.java:691) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.discovery.zen.UnicastZenPing.lambda$null$0(UnicastZenPing.java:212) ~[elasticsearch-5.6.3.jar:5.6.3]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_141]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:569) [elasticsearch-5.6.3.jar:5.6.3]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_141]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_141]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_141]
[2017-10-17T15:57:09,142][WARN][o.e.d.z.UnicastZenPing] [es-0] failed to resolve host [es-2:9300]
java.net.UnknownHostException: es-2

```

But when I hardcode the Pod IP (172.17.0.3:9300, 172.17.4:9300...) It seems to connect fine. Is there anything extra that i have to add when I want to use the pod names? Thanks!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 17, 2017, 4:04pm UTC](https://discuss.elastic.co/t/set-up-elasticsearch-to-use-pod-names-during-discovery-instead-of-pod-ip/104272/2 "2017-10-17T16:04:20Z")

</div>

`es-0` can't be resolved to an IP.  
Don't know exactly what pods are but is there any DNS like mechanism that you could use?

---

<div class="post-metadata">

**Author:** ![akpt](https://avatars.discourse-cdn.com/v4/letter/a/90db22/32.png) [@akpt](https://discuss.elastic.co/u/akpt)\
**Post date:** [October 17, 2017, 4:21pm UTC](https://discuss.elastic.co/t/set-up-elasticsearch-to-use-pod-names-during-discovery-instead-of-pod-ip/104272/3 "2017-10-17T16:21:24Z")

</div>

Sorry I should have specified. I'm using kubernetes (more specifically a minikube cluster) and so I have 3 pods created that should be es masters (as well as data/client). As for the DNS mechanism I'm not fully sure, but I was reading some kubernetes docs about [DNS](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/) and it did say that _ **pods are assigned a DNS A record in the form of** _  
`pod-ip-address.my-namespace.pod.cluster.local` and it also said that **Currently when a pod is created, its hostname is the Pod’s [metadata.name](http://metadata.name) value.**. So I assumed that using the pod name would work unless I misunderstood what was on the page.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 17, 2017, 9:19pm UTC](https://discuss.elastic.co/t/set-up-elasticsearch-to-use-pod-names-during-discovery-instead-of-pod-ip/104272/4 "2017-10-17T21:19:38Z")

</div>

I'm afraid I don't know. I believe it's more a K8s question though.

From elasticsearch point of view, you needs to provide an IP or a name that can be resolved to an IP.

---

<div class="post-metadata">

**Author:** ![akpt](https://avatars.discourse-cdn.com/v4/letter/a/90db22/32.png) [@akpt](https://discuss.elastic.co/u/akpt)\
**Post date:** [October 18, 2017, 3:40pm UTC](https://discuss.elastic.co/t/set-up-elasticsearch-to-use-pod-names-during-discovery-instead-of-pod-ip/104272/5 "2017-10-18T15:40:25Z")

</div>

Yeah it seems like there are some issues with kube-dns in my cluster which might be why I can't use the name

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 15, 2017, 3:40pm UTC](https://discuss.elastic.co/t/set-up-elasticsearch-to-use-pod-names-during-discovery-instead-of-pod-ip/104272/6 "2017-11-15T15:40:38Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
