# Docker swarm HA load balancing

**URL:** <https://forums.docker.com/t/docker-swarm-ha-load-balancing/70918>\
**Category:** General\
**Tags:** docker, swarm\
**Created:** [March 12, 2019, 11:51am UTC](https://forums.docker.com/t/docker-swarm-ha-load-balancing/70918 "2019-03-12T11:51:22Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![luukth](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@luukth](https://forums.docker.com/u/luukth)\
**Post date:** [March 12, 2019, 11:51am UTC](https://forums.docker.com/t/docker-swarm-ha-load-balancing/70918/1 "2019-03-12T11:51:22Z")

</div>

I’m currently experimenting with my raspberry pi cluster and HA. What happens when I point the DNS A record of [mycoolwebsite.com](http://mycoolwebsite.com) to node1 (192.168.1.100). When all of the nodes in the picture are running the ingress network from docker swarm will handle the request to the node with the container on it. But what happens if node1 goes down. The DNS record no longer works because nothing is listening on that ip.

I couldn’t find good documentation on this issue. Or is it an assumption that people running a docker swarm have a reverse proxy like nginx, HAProxy or traefik? I think treafik looked really cool, but that would run on a manager node, when that manager node goes offline. Your still left with nothing?

 ![Web%201920%20%E2%80%93%202](https://global.discourse-cdn.com/docker/original/3X/2/c/2c585061b18aac045b2fe8f4a6b1ca0342d6622f.png)

---

<div class="post-metadata">

**Author:** ![luukth](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@luukth](https://forums.docker.com/u/luukth)\
**Post date:** [July 11, 2019, 3:39pm UTC](https://forums.docker.com/t/docker-swarm-ha-load-balancing/70918/2 "2019-07-11T15:39:00Z")

</div>

Bump.  
Still haven’t figured out a solution for this problem.

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [July 11, 2019, 3:41pm UTC](https://forums.docker.com/t/docker-swarm-ha-load-balancing/70918/3 "2019-07-11T15:41:10Z")

</div>

This one might help you:

> [@Fault tolerance virtual IP](https://forums.docker.com/t/fault-tolerance-virtual-ip/77564/2):
>
> What you want is a floating IP. You can use Keepalived to create a setup that shifts a floating ip from one node to another. Check [https://github.com/osixia/docker-keepalived](https://github.com/osixia/docker-keepalived) for further details. Though, it can not be run as a swarm service. You might want to install it straight on your hosts or run it as a plain docker container (from cli or docker-compose).

Also: people usualy expose their swarm containers using a reverse proxy. Though, none of them solves the floating ip problem for you. Still, it is quite nice to have a single entrypoint like traefik that takes care of tls offloading and forwarding domain names or context paths to the target containers.

---

<div class="post-metadata">

**Author:** ![luukth](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@luukth](https://forums.docker.com/u/luukth)\
**Post date:** [July 11, 2019, 4:05pm UTC](https://forums.docker.com/t/docker-swarm-ha-load-balancing/70918/4 "2019-07-11T16:05:59Z")

</div>

Hi @meyay, Thanks for your reply. Traefik is a nice reverse proxy to use, only downside is the single point of failure. It is possible to cluster traefik but then my question still remains where do I point the DNS record.

This question might be an answer in the right direction: [https://serverfault.com/questions/919349/how-to-setup-traefik-for-ha-need-a-reverse-proxy-in-front-of-traefik](https://serverfault.com/questions/919349/how-to-setup-traefik-for-ha-need-a-reverse-proxy-in-front-of-traefik)

Especially option 3 seems like a good solution for a docker swarm. Just restrict the cloudflare ddns container placement to a manager node and the DNS record will always point to a working swarm manager. Downside is that this doesn’t work in a local development environment. And no 100% uptime.

My hope would be that someone with real world experience would share a strategy, or example use cases that are running in production.

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [July 11, 2019, 4:11pm UTC](https://forums.docker.com/t/docker-swarm-ha-load-balancing/70918/5 "2019-07-11T16:11:45Z")

</div>

uhm, did you read the link and access the keepalived container documentation?

---

<div class="post-metadata">

**Author:** ![luukth](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@luukth](https://forums.docker.com/u/luukth)\
**Post date:** [July 11, 2019, 4:29pm UTC](https://forums.docker.com/t/docker-swarm-ha-load-balancing/70918/6 "2019-07-11T16:29:11Z")

</div>

Oh yes of course, I’m sorry I forgot to mention that. I in fact actually tried that today before bumping this post. Both with local vm’s and with a floating IP on Hetzner. It worked great, it only takes a bit of time for the actual switching of the floating IP to happen.

Still hoping to explore more possible solutions to the problem.

> [@luukth](#):
>
> My hope would be that someone with real world experience would share a strategy, or example use cases that are running in production.

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [July 11, 2019, 4:58pm UTC](https://forums.docker.com/t/docker-swarm-ha-load-balancing/70918/7 "2019-07-11T16:58:45Z")

</div>

In production people rely on cloud loadbalancers like AWS ELBs or Hardware Loadbalancers.  
In a Test environment, I don’t see what’s wrong with keepalived…

---

<div class="post-metadata">

**Author:** ![luukth](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@luukth](https://forums.docker.com/u/luukth)\
**Post date:** [July 12, 2019, 12:03pm UTC](https://forums.docker.com/t/docker-swarm-ha-load-balancing/70918/8 "2019-07-12T12:03:04Z")

</div>

Yes your right, keepalived is perfect for local development. My raspberry pi’s are now running with keepalived and it’s awesome! The floating IP just switches when 1 manager(in a 3 manager node cluster) goes offline.

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [July 12, 2019, 2:58pm UTC](https://forums.docker.com/t/docker-swarm-ha-load-balancing/70918/9 "2019-07-12T14:58:22Z")

</div>

I know 🙂 Once you grow out of of Swarm and should move to Kubernetes (Ranchers k3s should be a good fit for the Pi) the keepalived solution can be replaced with MetalLB ([https://metallb.universe.tf/](https://metallb.universe.tf/), directly in Kubernetes).

---

<div class="post-metadata">

**Author:** ![kvdels](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/kvdels/32/50612_2.png) [@kvdels](https://forums.docker.com/u/kvdels)\
**Post date:** [August 24, 2024, 4:19am UTC](https://forums.docker.com/t/docker-swarm-ha-load-balancing/70918/10 "2024-08-24T04:19:00Z")

</div>

I use keepalived but I run it as a stack in the swarm, just like how metalLB does it. Its been running for months without issues

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/bluepuma77/32/32688_2.png) [@bluepuma77](https://forums.docker.com/u/bluepuma77)\
**Post date:** [August 26, 2024, 6:01am UTC](https://forums.docker.com/t/docker-swarm-ha-load-balancing/70918/11 "2024-08-26T06:01:39Z")

</div>

Hi @kvdels , could you share some more details?
