Docker群-添加新工作线程-重新扩展服务 [英] Docker swarm - add new worker - re scale the service

查看:107
本文介绍了Docker群-添加新工作线程-重新扩展服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个码头管理员。创建了一项服务,并在同一服务器上将其扩展到5个实例。

I have created a docker manager. Created a service and scaled to 5 instances in the same server.

我添加了两个工作线程。现在,如何在3个节点之间重新分配5个应用程序实例?

I added two workers. Now, How do I redistribute 5 instances of the applications across 3 nodes?

是否可以选择从一开始就不做任何事情?

Is there any option to do without doing everything from the beginning?

docker service scale id = 5 做到了。这是正确的方法吗?我不想重新启动现有实例。它在节点1重新启动。

docker service scale id=5 does it. Is it the right way? I don't want to restart already existing instances. It restarts at node 1.

docker服务更新服务名

我通过 docker swarm离开从集群中删除了一个节点。我更新了服务。我所有的实例都复制到其余节点中。

I remove one node from the cluster by docker swarm leave. I updated the service. All of my instances are replicated within remaining nodes.

很高兴,Update的工作符合预期。但是,还有另外一个转折。

Glad, Update worked as expected. But, there is another twist.

我将节点添加回去。然后,我更新了服务。现在,我所有的实例都像以前的情况一样运行。它不使用新节点。

I added the node back. Then I updated the service. Now, all of my instances are running as in the earlier case. It doesn't make use of the new node.

它是如何工作的?

推荐答案

要重新分发,您无需销毁并重新创建服务,但是所有容器将在滚动升级中退回。命令是 docker service update --force $ service_name

To redistribute, you don't need to destroy and recreate the service, but the containers will all be bounced in a rolling upgrade. The command is docker service update --force $service_name

添加或删除节点时,泊坞窗仅在当前状态与目标状态存在差异时才重新计划。在执行上述更新命令之前,它不会过早终止正在运行的容器以在新节点上重新计划。

When adding or removing nodes, docker will only reschedule when there is a difference between the current and target state. It doesn't prematurely kill running containers to reschedule then on new nodes until you do the above update command.

这篇关于Docker群-添加新工作线程-重新扩展服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆