What is the best practice to connect a Docker Swarm that is deployed in EC2 with an Application Load Balancer? In my configuration the ALB is what Route53 resolves to. The Docker Swarm is configured with three managers.
Things I have tried:
Initially I had only one target group associated with the ALB and the only target in it was the Docker Swarm leader. This seemed to work well but then I realized that if I have to do maintenance on the leader node, I have to demote and drain it so it will appear as not healthy to the ALB, causing downtime.
Then I replaced the only target group with a target group that contains all three managers. This also seemed OK, except that when I have to do maintenance - such as rebooting a server - then I have to manually go in the target group, deregister that server, demote and drain it from the swarm, reboot, put it back and promote in the swarm, and add it again to the target group. A tedious procedure.
Additionally, having all the managers in the target group is counter-intuitive to me, since the swarm has its own internal logic to distribute tasks.
What are the best practices in this scenario?