I need help setting up Traefik v2 and a simple whoami service with docker swarm. Here is my docker deploy yaml.
version: '3.7'
services:
reverse-proxy:
image: traefik:latest
command:
- "--api=true"
- "--log.level=DEBUG"
- "--providers.docker.swarmMode=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=proxy"
- "--entrypoints.web.address=:80"
ports:
- 80:80
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- proxy
deploy:
labels:
- "traefik.enable=true"
- "traefik.http.routers.api.rule=Host(`traefik.example.eu`)"
- "traefik.http.routers.api.entrypoints=web"
- "traefik.http.routers.api.service=api@internal"
# Dummy service for Swarm port detection. The port can be any valid integer value.
- "traefik.http.services.dummy-svc.loadbalancer.server.port=9999"
placement:
constraints:
- node.role == manager
- node.labels.number == one
whoami:
image: containous/whoami:latest
networks:
- proxy
deploy:
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=Host(`whoami.example.eu`)"
- "traefik.http.routers.whoami.entrypoints=web"
- "traefik.http.services.whoami.loadbalancer.server.port=80"
- "traefik.docker.network=proxy"
networks:
proxy:
external: true
If I deploy everything on one node it works fine. I can acces whoami.example.eu. If I add another node and set 'whoami' to run on the other node I get a Bad Getway response.
Other info:
All firewall ports are open on both nodes
I can see the service on the Traefik dashboard
Service IP is correct
I have been struggling with this for days now. Does anyone have an idea what I am doing wrong?
Okay, for swarm networking they need tcp/udp 2377,7946.
I would recommend adding another node in GCP/AWS to isolate the issue. Set the outside node availability to drain. See if it works. If it does you'll have to take a look at your inter cloud connectivity.
Thank you for your suggestion if I have both nodes on GoogleCloud it works. Network inspect returns the same as before but now I can access the whoami service.
I started with only the ports that you wrote. But as I was getting more desperate I did what I thought would help. For my defence, I am just learnig docker and traefik. And this are all testing machines.
Thank you again for your help and hopefully I will figure out what I have to do to make it work with different cloud providers. Have a nice day.