I have two swarm nodes (manager, worker) where I’ve installed mariadb galera cluster with docker containers. This part works properly.
In one node I have a load balancer (haproxy or pen) to make a load balancer. The load balancer works fine and the services are running but I want to have high availability in this infrastructure. Normally I install haproxy with keepalived to do this, but in this case, I don’t have idea to do this in docker. The main problem I have is the VIP of keepalived, how can I access to this IP from external clients?
I think for HA on swarm you need an L3 proxy routing ports to nodes that are exposing the ports for your application provided it can handle multiple instances.
You don’t need keepalived, as swarm mode comes with integrated routing mesh.
Just start as much replicas as you need with exposed port: docker service create --name my-ha-loadbalancer -p 3306:3306 --replicas 2 your-load-balancer-image
You can now acces your lb-instances from outside the cluster by any.public.ip:3306 and from inside your cluster by using the service name (my-ha-loadbalancer:3306)
In this case I need the external clients or applications pointing to 2 public.ip:3306, right?
There is some way to access with my.servicename:3306 from outside like inside?
Hi, you can create 2 entries for your my.servicename dns entry and clients should load balance the request between the dns entries. BUT it deepens on the client side to resend the request if the first node is down.
This works almost perfect with chrome and http request, but i’m not sure if sql client will do that.
i am also trying to use the same haproxy/keepalived setup with docker swarm. Would you be kind enough to share how you configure your keepalived config? I am using AWS and I have some issues with the internal IP mapping setup…