gpt4 book ai didi

azure - Traefik:Azure 上部署的 Swarm 模式下的错误网关

转载 作者:行者123 更新时间:2023-12-02 20:01:25 27 4
gpt4 key购买 nike

我目前正在尝试使用 Docker Swarm 模式部署一组微服务。我已经设置了一个 traefik 容器和我的所有容器,如下所示:

version: "3.4" 
networks:
backend-network:
external: true
services:

proxy:
image: traefik
command: --api --docker --docker.swarmMode --docker.watch
networks:
- backend-network
ports:
- "80:80"
- "8090:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
deploy:
replicas: 1
restart_policy:
condition: on-failure
placement:
constraints:
- node.role == manager

front-end:
image: *****
env_file:
- ./env/.react.env
networks: [ "backend-network" ]
ports:
- "8080:80"
deploy:
labels:
- traefik.enable=false
replicas: 1
restart_policy:
condition: on-failure
placement:
constraints:
- node.role == manager

users-db:
image: *****
networks: ["backend-network"]
ports: [ "5984:5984" ]
deploy:
labels:
- traefik.enable=false
replicas: 1
restart_policy: # restart if something went wrong
condition: on-failure

# server that listens HTTP requests
users:
image: *****
env_file:
- ./env/.users.env
# wait until service db is up
depends_on: [ "users-db" ]
networks:
- backend-network
# - proxy
# expose port 80 of host node
expose:
- "80"
deploy:
labels:
- traefik.port=80
- traefik.docker.network=backend-network
- traefik.frontend.rule=PathPrefixStrip:/api/auth/
- traefik.backend.loadbalancer.swarm=true
- traefik.backend.loadbalancer.stickiness=true
replicas: 1


shop:
image: *******
env_file:
- ./env/.shop.env
depends_on: [ "users"]
networks:
- backend-network
# - proxy
expose:
- "80"
deploy:
labels:
- traefik.port=80
- traefik.frontend.rule=PathPrefixStrip:/api/shop
- traefik.docker.network=backend-network
- traefik.backend.loadbalancer.swarm=true
- traefik.backend.loadbalancer.stickiness=true
replicas: 1


checkout:
image: *****
env_file:
- ./env/.checkout.env
depends_on: [ "users", "shop" ]
networks:
- backend-network
expose:
- "80"
deploy:
labels:
- traefik.port=80
- traefik.frontend.rule=PathPrefixStrip:/api/checkout
- traefik.docker.network=backend-network
- traefik.backend.loadbalancer.swarm=true
- traefik.backend.loadbalancer.stickiness=true
replicas: 1


visualizer:
image: dockersamples/visualizer:stable
ports: [ "9000:8080" ]
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
deploy:
labels:
- traefik.enable=false
placement:
constraints:
- node.role == manager

我用****隐藏了图像名称。

我在 Azure 上创建了两个虚拟机,我创建了 Swarm,Traefik 发现了我的服务,但是当我尝试使用 azure-dns/api/shop 发出请求时,它总是返回错误网关。

在本地使用docker-compose up时,它工作正常。我还没有在本地使用 docker-machine 尝试 Docker Swarm。我很快就会的。

最佳答案

验证backend-network是覆盖网络。

然后先尝试不使用

   - traefik.backend.loadbalancer.swarm=true
- traefik.backend.loadbalancer.stickiness=true # especially this one

根据问题 3770,粘性 session 在 v1.7 中似乎存在错误。

关于azure - Traefik:Azure 上部署的 Swarm 模式下的错误网关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53309230/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com