docker编排指定node

在Swarm模式下,如何通过编排指定service部署到哪些node上?

先为各个node添加label

docker node update --label-add zk=zk1 server1

然后创建service时,指定约束条件

docker service  create --name test --constraint "node.labels.zk==zk1" --replicas 5 redis

在编排文件中,需要这样指定:
      placement:
        constraints:
          - node.labels.zk == zk2

如果
  docker node update [OPTIONS] NODE
参数说明:
--availability string   Availability of the node ("active"|"pause"|"drain")
这个命令可以将该节点任务架空,比如我只想这个节点做管理,而不做worker。更新为drain状态

猜你喜欢

转载自godlewis.iteye.com/blog/2374128
今日推荐