docker swarm-如何平衡swarm集群中已在运行的容器? [英] docker swarm - how to balance already running containers in a swarm cluster?

查看:296
本文介绍了docker swarm-如何平衡swarm集群中已在运行的容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在AWS上有两个节点的docker swarm集群。我停止了这两个实例,并最初启动了swarm manager,然后启动了worker。在停止实例之前,我运行的服务带有在Manager和worker之间分配的4个副本。

当我启动swarm manager节点时,所有副本容器首先在Manager本身上启动,而根本没有移到worker。

请告诉我如何进行负载平衡?

工作者启动时,集群管理器不负责吗?

I have docker swarm cluster with 2 nodes on AWS. I stopped the both instances and initially started swarm manager and then worker. Before stopped the instances i had a service running with 4 replicas distributed among manager and worker.
When i started swarm manager node first all replica containers started on manager itself and not moving to worker at all.
Please tell me how to do load balance?
Is swarm manager not responsible to do when worker started?

推荐答案

如果服务处于默认的复制模式,则在启动新节点时,当前(18.03)群不会移动或替换容器。这是设计使然。如果要添加新节点,则不必停止其他容器,而要在新节点上创建新容器。 Swarm仅在必须(以复制模式)时停止容器以移动副本。

Swarm currently (18.03) does not move or replace containers when new nodes are started, if services are in the default "replicated mode". This is by design. If I were to add a new node, I don't necessarily want a bunch of other containers stopped, and new ones created on my new node. Swarm only stops containers to "move" replicas when it has to (in replicated mode).

docker服务更新--force< servicename> 将在满足其需求和约束的所有节点之间重新平衡服务。

docker service update --force <servicename> will rebalance a service across all nodes that match its requirements and constraints.

进一步建议:与其他容器协调器一样,您需要在您的节点,以便处理在中断期间移动的任何服务副本的工作负载。您的备用容量应与计划支持的冗余级别相匹配。例如,如果您要处理两个节点同时发生故障的容量,则需要在所有节点上使用最少百分比的资源,以使这些工作负载转移到其他节点。

Further advice: Like other container orchestrators, you need to give capacity on your nodes in order to handle the workloads of any service replicas that move during outages. You're spare capacity should match the level of redundancy you plan to support. If you want to handle capacity for 2 nodes failing at once, for instance, you'd need a minimum percentage of resources on all nodes for those workloads to shift to other nodes.

这篇关于docker swarm-如何平衡swarm集群中已在运行的容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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