Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Swarm Windows Worker with Traefik returns Gateway Timeout

The objective is to get a mixed OS Docker swarm running using Linux servers and Windows 10 Machines running Docker For Windows

Currently Windows workers are theoretically supported on mixed os swarms provided the --endpoint-mode flag is set to 'dnsrr'. This is explained here. However attempts to use traefik to route to a simple docker whoami image stefanscherer/whoami image have failed.

Minimal Failing Example

// On (Linux) Manager Node:
docker swarm init --advertise-addr <hostaddress> --listen-addr <hostaddress>:2377

// On (Windows 10) Worker Node:
docker swarm join <jointoken>

// On Manager Node:
docker network create --driver=overlay traefik-net

docker service create \
    --name traefik \
    --constraint=node.role==manager \
    --publish 80:80 --publish 8080:8080 \
    --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
    --network traefik-net \
    traefik \
    --docker \
    --docker.swarmmode \
    --docker.domain=traefik \
    --docker.watch \
    --web

docker service create \
    --name whoami \
    --label traefik.enable=true \
    --label traefik.frontend.rule=Host:whoami.docker \
    --label traefik.protocol=http \
    --label traefik.docker.network=traefik-net \
    --label traefik.backend.loadbalancer.method=drr \
    --label traefik.backend=whoami \
    --network traefik-net \
    --mode global\
    --label traefik.port=80 \
    stefanscherer/whoami

Traefik successfully sets up backend rules, to check the routing I used the traefik dashboard to find out the URL that is routed to by the rule e.g. '10.0.0.12:8080'. I then compare this with the IP address of each task, the task can be viewed with docker service ps, and their address' found using

docker inspect <taskID> \
    --format '{{ range .NetworksAttachments }}{{ .Addresses }}{{ end }}'

The Problem

A HTTP request with a header 'Host:whoami.docker' sent to the IP of the manager will succeed when routed to the manager and fail with 504 Gateway Timeout when routed to the Windows Task on the Windows worker.

like image 396
Matt Hawes Avatar asked Aug 22 '17 16:08

Matt Hawes


1 Answers

You're missing setting --endpoint-mode=dnsrr to your whoami service.

docker service create \
--name whoami \
--label traefik.enable=true \
--label traefik.frontend.rule=Host:whoami.docker \
--label traefik.protocol=http \
--label traefik.docker.network=traefik-net \
--label traefik.backend.loadbalancer.method=drr \
--label traefik.backend=whoami \
--network traefik-net \
--mode global\
--label traefik.port=80 \
--endpoint-mode=dnsrr
stefanscherer/whoami

Setting endpoint-mode dnsrr will disable VIP address which probably is causing the issue.

like image 57
Miq Avatar answered Oct 18 '22 10:10

Miq