For joining a new agent into a group of consul members, one needs to know the IP of at least one existing member. I have to support a scenario in which I do not know an IP of any existing group members. Human intervention is not possible in this situation as a the service discovery has to run completely automatically.
My idea to solve this: I could send a message via broadcast or multicast to other computers in the network. Every computer hosts a custom service that I will implement. That service replies to this special broadcast/multicast message (e.g.: "Looking for existing cluster members") with the IP address to which the consul is listening. The service will then get one or more replies from the network and use one of the IP addresses to join the cluster.
Does anyone have a better idea to solve this problem? Are there any existing libraries to solve this?
Hashicorp provides a free service as part of Atlas to do just that: https://www.consul.io/docs/guides/atlas.html
The other easier ways to do it without a custom service: