I would like to scale my Docker webapp and make it highly available. I have been using Docker for many years and K8s seems overly complicated, therefore I am looking into Docker Swarm.
The idea is to have an external highly available load balancer as first contact, forwarding all TCP/IP traffic to 3 Docker Swarm master nodes with Traefik 2.4 listening directly on the servers port (0.0.0.0:80). Traefik uses the http domain configured in the service to forward it to an appropriate container on one of the workers over the Docker network.
For simplicity this is just plain http, not even that is working for me. The load balancer is configured correctly, the Docker Swarm is up and running. This is how I start the services:
For some reason there seems to be an error in the configuration. I have been trying to tweak it, but I either get an empty response or 404 page not found when using curl . Latest error is level=error msg="Skip container : field not found, node: enabled" providerName=docker .
Assumptions:
Traefik is running on Swarm master nodes to get Docker event notifications
Traefik is listening directly on external port 80 of master nodes
Traefik will recognize new services and route to containers based on domain name
Multiple webapp container of the same service can run on the same worker node
Questions:
How do I get the basic version up and running? Where is the mistake?
How do I access Traefik dashboard? I assume every dashboard will show different data.
How to add own SSL certificates to Traefik? Do Swarm services support local storage?
(I am for easy solutions, happy to copy my .pem on all 3 nodes, once every year)
Otherwise I am interested in any kind of feedback about the planned architecture.
TraefikEE supports this clustered solution. Without that you would have 3 independent Traefiks.
Yes Swarm supports local storage in the form of a Volume. docker cp can be one way to get files in. Or bind mount a local copy and the volume with a utility container(bash) and copy them that way.
Did you know you can use a compose file for a stack deploy too?
I traveled the whole world wide web in search for a dead simple solution to run Traefik 2.4 in Docker Swarm, to no avail. Would you like to help out making this post the reference by providing a working example? This could even be a fantastic blog post: the easy way for developers: from container to scale with Traefik and Docker Swarm It just needs 2 commands:
docker service create --name traefik ...
docker service create --name webapp ...
PS: I admit I like plain CLI commands better, probably because I want to start and update 50+ services programmatically. Plus I feel it's shorter and you can still move to compose later.
2021-05-20T21:51:14.956805457Z time="2021-05-20T21:51:14Z" level=debug msg="Configuration received from provider docker: {\"http\":{\"routers\":{\"hostname\":{\"entryPoints\":[\"web\"],\"service\":\"hostname\",\"rule\":\"Host(`lb.domain.tld`)\"}},\"services\":{\"hostname\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://10.0.6.39:80\"},{\"url\":\"http://10.0.6.42:80\"},{\"url\":\"http://10.0.6.41:80\"},{\"url\":\"http://10.0.6.37:80\"},{\"url\":\"http://10.0.6.40:80\"},{\"url\":\"http://10.0.6.38:80\"}],\"passHostHeader\":true}}}},\"tcp\":{},\"udp\":{}}" providerName=docker
Just an external web browser still gets "404 page not found", seems Traefik is not forwarding.