zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    ROS+clion多节点调试
    argparse模块用法实例详解
    Python3中的bytes和str类型
    elk日志过滤文档
    centos7普通用户无法切换为root用户处理
    Hyper-V迁移方案
    中小互联网电商(电商)公司研发部门组织架构
    基于Redis实现令牌桶限流
    异步与协程
    C# 同步上下文及死锁
  • 原文地址:https://www.cnblogs.com/rancher-maomao/p/9978377.html
Copyright © 2011-2022 走看看