基本的Traefik配置问题

时间:2019-06-21 09:15:40

标签: traefik

首先,我想实现“交通入门”页面上所述的基本交通配置。以下是我的撰写和toml文件。当我扩展whoami服务时,我看到了许多前端……没有负载平衡。知道配置错误吗?非常感谢-克里斯蒂安

Docker Compose:

version: '3'
services:
  traefik:
    image: traefik # The official Traefik docker image
    command: --api --docker # Enables the web UI and tells Traefik to listen to docker
    ports:
      - "80:80"     # The HTTP port
      - "9090:8080" # The Web UI (enabled by --api)
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
      - /home/traefik:/etc/traefik # Where the Traefik configuration is

  whoami:
    image: containous/whoami
    labels:
      - "traefik.enable=true"
      - "traefik.frontend.rule=Host:whoami.docker.localhost"

Traefik.toml

defaultEntryPoints = ["http"]

[entryPoints]
  [entryPoints.http]
  address = ":80"

[frontends]
  rule = "Host:whoami.docker.localhost"

[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "docker.localhost"
swarmMode = true
exposedByDefault = false

更新: 我在其他线程上看到,在Swarm节点上,也需要配置traefik端口。因此,以下是我在群集管理器节点(管理器和工作程序节点位于同一平台上的试用平台)上用于部署堆栈的命令和撰写文件。但是,这不会修改最终结果,即Traefik无法看到该服务:

docker stack deploy -c docker-compose-traefik-stack.yml traefik_stack

    version: '3'
services:
  traefik:
    image: traefik # The official Traefik docker image
    command: --api --docker # Enables the web UI and tells Traefik to listen to docker
    ports:
      - "80:80"     # The HTTP port
      - "9090:8080" # The Web UI (enabled by --api)
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
      - /Users/obech01/Runtime/traefik:/etc/traefik # Where the Traefik configuration is

  whoami:
    image: containous/whoami
    deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.frontend.rule=Host:whoami.docker.localhost"
        - "traefik.backend=whoami"
        - "traefik.port=8000"

0 个答案:

没有答案