How does a Consul agent know it is the leader of a cluster?

前端 未结 5 2065
既然无缘
既然无缘 2021-02-14 09:40

In Consul you can have many agents as servers or clients. Amongst all servers one is chosen as the leader. From the agent\'s point of view, how does it know it is the leader?

5条回答
  •  长发绾君心
    2021-02-14 09:51

    One way is by calling the cluster with http://:8500/v1/status/leader

    This will return the current leader. Then just check the IP address returned against the local IP address.

提交回复
热议问题