Technical question about DNS implementation

Hi, I’m trying to set up a bulletproof Zookeeper install and in the process learning a lot about service discovery in Rancher

My question lies in the implementation of DNS between instances of the same service. If I have three instances of the same service and I ping the service name I get an IP at random. It does however appear that my own IP is the IP of last resort, ie the default will be one of my peers at random. Can you confirm that? Can I assume that if I resolve my service name and get my IP that I’m all alone and need to be the master?

The DNS server returns the IPs of all the containers, in a random order. If you do something like dig A zookeeper you will see multiple A records returned.

The client will then typically choose one of those at random (or not so random). So that is not a valid assumption. You’ll need to communicate or use metadata to decide who the master should be. There already exists a Zookeeper template in the Catalog which I believe handles this that you could either just use, or learn from.

I managed to work round this another way getent hosts <service> works fine