consul icon indicating copy to clipboard operation
consul copied to clipboard

How should I use one ip to access the consul cluster.

Open Silence2012 opened this issue 9 years ago • 9 comments

How should I use one ip to access a consul cluster. For example there is 3 nodes consul cluster consul node 1 : 10.10.10.2:8500 leader consul node 2 : 10.10.10.3:8500 follow consul node 3 : 10.10.10.4:8500 follow

How should I use one ip + port to access the consul cluster without inviting other software like nginx?

Silence2012 avatar Sep 15 '17 02:09 Silence2012

Any type of load balancer, such as haproxy, nginx, f5, etc, or even just as simple as a VIP, setup with keepalived. Consul UI is treated like any other web service for that purpose.

jfgibbins avatar Sep 18 '17 09:09 jfgibbins

You should not put consul behind a load balancer but instead install a local agent on all of your nodes and then connect to localhost:8500. The requests will be automatically forwarded to the current leader.

magiconair avatar Sep 20 '17 07:09 magiconair

@magiconair Yes, that would be true for applications that are using consul, but you certainly wouldn't install it on your local pc to access for management, so yes, there is reason to want to have it behind a cluster ip. Unfortunately consul does not handle VIP on its own, so if you want to access it from a non-agent machine, the servers would need to be put behind a lb or vip. I personally run it on top of docker swarm, which handles it using the ingress network, but that requires some adjustments, as consul's method of storing server IPs in raft, is rather crippling.

jfgibbins avatar Sep 20 '17 11:09 jfgibbins

@jfgibbins Did you have some tricks about this?

Saliva520319 avatar Nov 10 '17 07:11 Saliva520319

The best way to deal with the PC use case is probably via DNS (configure a DNS name with the Consul servers, for example) or some kind of LB or proxy, but for all other use cases we definitely recommend running the agent. Hope that helps!

slackpad avatar Dec 20 '17 00:12 slackpad

any LB or proxy suggestion?@slackpad

Jaware avatar Dec 20 '17 06:12 Jaware

@Jaware Hello, have you solved this problem? How do you connect to the consul cluster now, Did you use the LB or proxy ?

ghost avatar Nov 15 '18 07:11 ghost

One option is to use DNS forwarding in the local network. You can then point your browser at http(s)://consul.service.[dc].consul/

ferrix avatar Nov 28 '18 16:11 ferrix

write little lb code yourself, just a for loop

Jaware avatar Jan 19 '19 08:01 Jaware