Reputation: 547
I have some small cluster managed with Rancher. There are only two workers : node1 and node2.
I could add a stack1, add a load-balancer for this stack or global and it works fine. But I have some problem with DNS.
I could point stack1.domain.com to node1.domain.com for example. My load-balancer is running on the node1 (or even on all the nodes of my cluster) so it works.
But if one day I need to shut down my node1, I have to go quickly and point DNS stack1.domain.com to node2.domain.com Not a good idea.
My first thought was to use a small haproxy server in front of my Rancher cluster.
So, I point stack1.domain.com to haproxy.domain.com and then haproxy backend it to node1 and node2.
But it does not work.
I could put something like that
frontend http *:80
acl stack1 hdr(host) -i stack1.domain.com
use_backend bck_s1 if stack1
backend bck_s1
mode http
balance roundrobin
server n1 node1.domain.com:80 check
server n2 node2.domain.com:80 check
Probably it could work. But if I need to add stack2 that listen on 80 port as well, I could not use this schema.
I could add bck_s2, but it will point to the same node1/node2. So rancher will not understand if I want stack1 or stack2?
It's possible to resolve it using different ports, but it seems not a good idea. Certainly I could listen stack1 to 80 port, stack2 to 8080, but if I have stack3, 4,... it became too complex.
I had an idea to add some path to backend. Like this :
backend bck_s1
mode http
balance roundrobin
server n1 node1.domain.com:80/s1 check
server n2 node2.domain.com:80/s1 check
In this case I could put a load-balancer on the Rancher based on rule /s1, /s2 etc. But it seems that it's not possible to do this using haproxy. Am I right?
So the questions.
1) Is it possible to realize it using haproxy and how to do it?
2) Are there some others solutions that I could use?
Upvotes: 0
Views: 1753
Reputation: 1960
Instead of using specific entries in haproxy.domain.com
, you could configure a wildcard entry, point to both the nodes along with configuring healthcheck for the backend. That way when you take down node-1, HA proxy can detect it and not direct traffic to that node anymore. Things would be more dynamic this way on the HA Proxy side and you wouldn't need to make DNS changes.
References: - Wildcard in subdomain for ACL in HAPROXY
Upvotes: 1