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

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

问题描述

我在 AWS 上有 2 个节点的 docker swarm 集群.我停止了这两个实例,最初启动了 swarm manager,然后启动了 worker.在停止实例之前,我有一个服务正在运行,其中有 4 个副本分布在经理和工作人员之间.
当我首先启动 swarm manager 节点时,所有副本容器都在 manager 本身上启动,并且根本没有移动到 worker.
请告诉我如何做负载均衡?
swarm 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?

推荐答案

如果服务处于默认的复制模式",Swarm 当前(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 service update --force <servicename> 将在符合其要求和约束的所有节点之间重新平衡服务.

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

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

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 - 如何平衡集群中已经运行的容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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