• Docker Swarm集群中部署Traefik负载均衡器


    一、创建单节点的Docker Swarm集群

    docker swarm init

    二、在Swarm集群中创建一个网络

    docker network create --driver=overlay traefik --attachable

    三、在Swarm集群中部署traefik负载均衡器服务

    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

    traefik

    --docker

    --docker.swarmmode

    --docker.domain=traefik

    --docker.watch

    --web

     

    四、在Swarm集群中分别部署2个容器服务(httpdnginx

    #2.1 httpd.abc.com

    docker service create

    --name httpd

    --network traefik

    --label "traefik.backend=httpd"

    --label "traefik.enable=true"

    --label "traefik.protocol=http"

    --label "traefik.port=80"

    --label "traefik.frontend.rule=Host:httpd.abc.com"

    httpd

     

    #2.2 nginx.abc.com

    docker service create

    --name nginx

    --network traefik

    --label "traefik.backend=nginx"

    --label "traefik.enable=true"

    --label "traefik.protocol=http"

    --label "traefik.port=80"

    --label "traefik.frontend.rule=Host:nginx.abc.com"

    nginx

     

     

    五、在浏览器中通过域名访问2个网站、查看Traefik UI

    #修改Win7客户端电脑的hosts文件C:WindowsSystem32driversetchosts

    #增加2条主机记录:

    httpd.abc.com 192.168.3.168

    nginx.abc.com 192.168.3.168

     

    http://192.168.3.168:8080

    http://httpd.abc.com

    http://nginx.abc.com

     

     

    六、Swarm集群中服务扩容后,再查看Traefik UI

    docker service scale httpd=2

    docker service scale nginx=3

     

    http://192.168.3.168:8080

     

    附图:

      

     

     

     

     

     

     

     

     

     

     

     

    参考链接:

    docker swarm模式使用traefik部署服务

    http://blog.51cto.com/6764097/2066670

     

    Docker Swarm (mode) cluster

    http://docs.traefik.cn/user-guide/swarm-mode

  • 相关阅读:
    IE浏览器下常见的CSS兼容问题
    Android studio 使用问题汇总
    IOS中的属性列表----Property List
    自定义组件-BreadcrumbTreeView 的使用
    IOS开发之数据sqlite使用
    深入分析动态管理Fragment
    IOS开发中多线程的使用
    Java中导入、导出Excel
    IOS数据持久化之归档NSKeyedArchiver
    Bugfree3.0.4 Linux环境安装指南
  • 原文地址:https://www.cnblogs.com/rancher-maomao/p/9978377.html
Copyright © 2020-2023  润新知