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

Created on 15 Sep 2017  路  9Comments  路  Source: hashicorp/consul

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?

Most helpful comment

@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.

All 9 comments

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.

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 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 Did you have some tricks about this?

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!

any LB or proxy suggestion?@slackpad

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

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

write little lb code yourself, just a for loop

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wargamez picture wargamez  路  4Comments

powerman picture powerman  路  3Comments

atomantic picture atomantic  路  4Comments

wing731 picture wing731  路  3Comments

hooksie1 picture hooksie1  路  3Comments