使用docker machine创建swarm集群

  1. 准备干净的vm模版,clone出4台。ip规划如下
    • enp0s3 外网网卡,桥接模式,dhcp
    • enp0s8 内网网卡,bridge到bridge0(192.168.1.1/24)
  2. 打通centos-console 到其他几个服务区的信任登陆
    • centos-console 192.168.1.10
    • centos-test1 192.168.1.11
    • centos-test2 192.168.1.12
    • centos-test3 192.168.1.13
  3. 在跳板机器创建consul容器,做服务发现
    docker run --restart=always -d -p 8500:8500 --name=consul progrium/consul -server -bootstrap
  4. 创建swarm-master
    docker-machine create --driver generic --generic-ip-address 192.168.1.11 --generic-ssh-user root --engine-registry-mirror=https://wfsgsp6x.mirror.aliyuncs.com --engine-install-url=https://get.daocloud.io/docker/ --swarm --swarm-master --swarm-discovery="consul://192.168.1.10:8500" node-master
  5. 创建node
    docker-machine create --driver generic --generic-ip-address 192.168.1.12 --generic-ssh-user root --engine-registry-mirror=https://wfsgsp6x.mirror.aliyuncs.com --engine-install-url=https://get.daocloud.io/docker/ --swarm --swarm-discovery="consul://192.168.1.10:8500" node-woker1
    docker-machine create --driver generic --generic-ip-address 192.168.1.13 --generic-ssh-user root --engine-registry-mirror=https://wfsgsp6x.mirror.aliyuncs.com --engine-install-url=https://get.daocloud.io/docker/ --swarm --swarm-discovery="consul://192.168.1.10:8500" node-woker2
  6. 查看machine
    [root@centos-console cert]# docker-machine ls
    NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
    node-master - generic Running tcp://192.168.1.11:2376 node-master (master) v1.12.0
    node-woker1 - generic Running tcp://192.168.1.12:2376 node-master v1.12.0
    node-woker2 - generic Running tcp://192.168.1.13:2376 node-master v1.12.0
  7. 登陆管理
    docker -H 192.168.1.11:3376 --tlsverify --tlscacert=/root/cert/ca.pem --tlscert=/root/cert/server.pem --tlskey=/root/cert/server-key.pem info
此条目发表在docker, System分类目录。将固定链接加入收藏夹。

发表评论