Hi all.
After 3 day of search, mostly looping on the same page, in stay without any solution for setting up a little stack that on only involve traefik and its whoami service.
I've setup a swarm cluster. I think it works well but perhaps I've missed something there.
I've create an attachable overlay network
Then I've started with a docker compose service that works perfectly ... But only on the node I declare it.
Here is the code used (not sure how to enter code here, I hope it will be readable)
services:
traefik:
image: traefik:{{ trfversion }}
restart: unless-stopped
networks:
trf-{{ clustername }}:
security_opt:
- no-new-privileges:true
command:
- --accesslog=true
- --accesslog.filepath=/tmp/access.log
- --log=true
- --log.level=TRACE
- --log.filepath=/tmp/traefik.log
- --api=true
- --api.dashboard=true
- --api.debug=true
- --api.disabledashboardad=true
- --api.insecure=true
- --providers.docker=true
- --providers.docker.exposedbydefault=true
- --providers.docker.network=trf-{{ clustername }}
- --providers.docker.endpoint=unix:///var/run/docker.sock
- --providers.file.directory=/etc/traefik/dynamic_conf
- --entryPoints.http.address=:80
- --entrypoints.http.http.redirections.entryPoint.to=https
- --entrypoints.http.http.redirections.entryPoint.scheme=https
- --entrypoints.http.http.redirections.entrypoint.permanent=true
- --entrypoints.https.address=:443
- --serverstransport.insecureskipverify=true
ports:
- "80:80"
- "443:443"
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- /mnt/traefik/data/certconf.yml:/etc/traefik/dynamic_conf/conf.yml:ro
- /mnt/traefik/certs:/certs
- /mnt/traefik/logs/:/tmp/
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.rule=Host({{ traefik_fqdn }}
)"
- "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
- "traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https"
- "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
- "traefik.http.routers.traefik-secure.entrypoints=https"
- "traefik.http.routers.traefik-secure.rule=Host({{ traefik_fqdn }}
)"
- "traefik.http.routers.traefik-secure.tls=true"
- "traefik.http.routers.traefik-secure.service=api@internal"
whoami:
image: "traefik/whoami"
networks:
trf-{{ clustername }}:
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=Host(whoami.xcorp.net
)"
- "traefik.http.routers.whoami.entrypoints=https"
- "traefik.http.routers.whoami.tls=true"
- "traefik.http.services.whoami-service.loadbalancer.server.port=80"
networks:
trf-{{ clustername }}:
external: true
I certainly used more option than needed but this allow me to be sure on the settings
Like I said everything works, I can reach the fqdn of traefik in http/https which redirect to the dashboard and reaching the whoami url succeed also.
Now from there I try to make it a little more HA and convert the code to a stack to deploy.
The modification involved mainly to move the labels under the deploy tag and add the "swarm related" command parameters in the command: section.
The documentation is so bad for that on V3 ... My understanding is that you introduce a new provider but you still use the docker provider.
Anyway, when I deploy the stack, nothing work anymore. Same unmodified cluster, both container fixed to the first node for debugging purpose.
I get no error in the traefik logs that I monitor. I have regular update saying
2024-08-06T09:38:12Z DBG github.com/traefik/traefik/v3/pkg/server/configurationwatcher.go:227 > Configuration received config={"http":{"middlewares":{"sslheader":{"headers":{"customRequestHeaders":{"X-Forwarded-Proto":"https"}}},"traefik-https-redirect":{"redirectScheme":{"scheme":"https"}}},"routers":{"traefik":{"middlewares":["traefik-https-redirect"],"rule":"Host(proxdnl.xcorp.net
)","service":"dashboard"},"traefik-secure":{"entryPoints":["https"],"rule":"Host(proxdnl.xcorp.net
)","service":"api@internal","tls":{}},"whoami":{"entryPoints":["https"],"rule":"Host(whoami.xcorp.net
)","service":"whoami-service","tls":{}}},"services":{"dashboard":{"loadBalancer":{"passHostHeader":true,"responseForwarding":{"flushInterval":"100ms"},"servers":[{"url":"http://30.20.0.11:8080"}]}},"whoami-service":{"loadBalancer":{"passHostHeader":true,"responseForwarding":{"flushInterval":"100ms"},"servers":[{"url":"http://30.20.3.140:80"}]}}}},"tcp":{},"tls":{},"udp":{}} providerName=swarm
Nothing in the access.log and an ERR_CONNECTION_REFUSED on each url.
I'm lost.
An advise on how I can debug this ?
Could it be my traefik config that miss somthing or more a problem on my swarm network routing ?
By advance thanks for all the help you could provide
Regards
Stef