Docker Community Forums

Share and learn in the Docker community.

High availability on SWARM


(Cristian Martínez) #1

Hello

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?

Any ideas?

Thanks in advance


(Archimedes Trajano) #2

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.


(Cristian Martínez) #3

First, thanks for your reply
Do you refer to exposing ports with -P option?

I do this for the load balancer but I don’t know how i should do with Virtual IP of keep alived.

More or less this is the architecture that I need. Is in the yellow part where I’m confused.
Any ideas?


(Archimedes Trajano) #4

With the -p but yes. As for the yellow area not really sure.


(Nikolas Hermann) #5

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)

For more information see: https://docs.docker.com/engine/swarm/ingress/


(Cristian Martínez) #6

Thanks for your reply

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?


(Eldeberde) #7

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.

Also can use dockerized keepalived to share a virtual ip between all nodes: https://github.com/osixia/docker-keepalived

Regards


(Cristian Martínez) #8

Hi @eldeberde

Finally, I configured an external haproxy+Keepalived to do high available the galera cluster

Thanks a lot for your reply