For the workers to be able to connect to the master, they first need to be aware of its existence! Depending on our particular use case, the following discovery strategies can be used:
- Connecting to a bootstrap node: This discovery strategy assumes that one of the master nodes (commonly referred to as the bootstrap node) is reachable at an IP address that is known beforehand. Both masters and workers attempt to establish an initial connection to the bootstrap node and obtain information about the other nodes of the cluster using a gossip protocol.
- Using an external discovery service: This strategy relies on the presence of an external discovery service that we can query to obtain information about all services running inside our cluster. Consul [1] is a very popular solution for implementing this particular pattern.
- Locating nodes using DNS records: If our system is deployed inside an environment that allows us to create and manipulate local DNS records (for example, Kubernetes), we can generate A records that point to the leader of the cluster. Workers can look up the leader via a simple DNS query.