I'm trying to setup a docker based system with the least amount of network abstraction/virtualization possible. This is why I avoided k8s and am trying docker-swarm instead.
I'd like haproxy to be started directly via systemd and listen to external traffic on ports 80/443 directly, i.e. without docker coming into the picture. However, when proxying traffing to backend servers, I'd like it to connect to docker-swarm services running in dnsrr mode.
How do I set this up? I've read this blog post multiple times, but in all three configurations it seems that haproxy itself is running as a docker-swarm service. I do not want any network "abstraction" to come between haproxy and customer-facing traffic.
Is a setup like this possible?
PS: A related question might be, how do I communicate between the host and a docker-swarm container running on the same host? I tried pinging 10.0.6.75 (the container's IP address) on the same host on which it was running, but it didn't work. Do I need to create some network route, or make some entry in iptables to get this to work?
If you use docker, you can't avoid a layer of network abstraction, because it creates a virtual network with it's own routes and should be inaccesible to your host networks by default.
If all you want is to make docker services accessible without the hassle, I'd recommend you to use traefik to track docker services instead of haproxy. But, if you insist in using HAproxy, you can either:
Run haproxy inside a docker container
And expose it to the host network.
Use a host networking for your docker services
Manually bind the HAproxy service to the network interface(s)
Inspect the docker network for your services.
Add to your haproxy configuration: