因此,我需要多播群集流量,因此我在群集范围内创建了“ macvlan”驱动程序netowrk。 IP范围是运行docker的主机的地址。
#docker network create --config-only --subnet 192.168.0.0/24 -o parent=eth0 --ip-range 192.168.0.100/24 test
#docker network create -d macvlan --scope swarm --config-from test test_net
撰写文件如下:
version: "3"
services:
lb:
image: 'dockercloud/haproxy:latest'
links:
- web
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- '81:80'
- '1936:1936'
deploy:
restart_policy:
condition: any
mode: replicated
replicas: 1
update_config:
delay: 2s
placement:
constraints: [node.role == manager]
networks:
- test_net
whoami:
image: tutum/hello-world
networks:
- test_net
environment:
- "SERVICE_PORTS=80"
- "COOKIE= SRV insert indirect preserve nocache"
ports:
- "80"
deploy:
restart_policy:
condition: any
mode: replicated
replicas: 5
update_config:
delay: 2s
labels:
- "traefik.docker.network=test_net"
- "traefik.port=80"
- "traefik.frontend.rule=PathPrefix:/"
- "traefik.backend.loadbalancer.sticky=true"
loadbalancer:
image: traefik
command: --docker \
--docker.swarmmode \
--docker.watch \
--web \
--loglevel=DEBUG
ports:
- 80:80
- 9090:8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock
deploy:
restart_policy:
condition: any
mode: replicated
replicas: 1
update_config:
delay: 2s
placement:
constraints: [node.role == manager]
networks:
- test_net
networks:
test_net:
external: true
当堆栈上升时,traefik会选择不在macvlan范围内的内部IP网络。
docker deploy -c docker-compose.yml test
Traefik从入口网络中选择不可用的IP并导致“网关超时”
如何使traefik正确到达节点?