I would like to scale my little 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 simple: have a 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. 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 we leave out https for now, as even plain http is not working for me. The load balancer is configured correctly, the Docker Swarm is up and running. This is how I start the services:
sudo docker network create --driver=overlay traefik-public # reverse proxy service sudo docker service create \ --name traefik \ -p 80:80 \ --mount type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock \ --mode=global \ --constraint node.role==manager \ --network traefik-public \ traefik:2.4 \ --providers.docker.swarmMode=true \ --providers.docker.endpoint=unix:///var/run/docker.sock \ --providers.docker.exposedbydefault=false \ --providers.docker.watch=true \ --providers.docker.network=traefik-public \ --entryPoints.web.address=:80 # webapp A service sudo docker service create \ --replicas 5 \ --name hostname \ --constraint node.role!=manager \ --network traefik-public \ --publish published=8080,target=80 \ --label traefik.enabled=true \ --label 'traefik.http.routers.hostname.rule=Host(`a.domain.tld`)' \ --label traefik.http.routers.hostname.entrypoints=http \ --label traefik.http.services.hostname.loadbalancer.server.scheme=http \ --label traefik.http.services.hostname.loadbalancer.server.port=8080 \ nginxdemos/hello
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 http://a.domain.tld. Latest error is
level=error msg="Skip container : field not found, node: enabled" providerName=docker.
- 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
Main Question: how do I get the basic version up and running? What's wrong?
Can I use env variables with services like with containers (for DB connection string)?
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)
How do I enable SSL and http redirect to https?
Can I add paths to domains so
http://a.domain.tld/apiuses a different service?
How to collect container logs? Will Elastic Filebeat work with worker containers?
Otherwise I am happy for any kind of feedback about the planned IT architecture.