Docker群只在工作中运行任务 [英] Docker swarm run tasks only in workers

查看:148
本文介绍了Docker群只在工作中运行任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我们正在使用群组模式,我们有三个节点:




  • manager1

  • worker1

  • worker2



是否可以创建一个服务并指定只有这些任务必须在工作人员(worker1和worker2)中运行,而不是在管理员(manager1)中运行



我正在运行以下命令来创建服务:

  docker-machine ssh manager1docker service create --network dognet --name dog-db redis

,当我服务时:

  docker-machine ssh manager1docker service ps dog-db

我得到:

  ID名称图像节点想要的状态当前状态错误
3kvfpbhl6fj0qwtglc5k7sbkw dog-db.1 redis manager1运行准备4秒前


解决方案

虽然您可以使用约束(使用 - constraint node.role = worker )根据其角色来消除节点的一​​个子集(manager或worker ),我会去,只要禁止管理员像工作人员一样执行

 #禁用管理器作为工作节点

停靠点节点更新 - 可用性管理器1

这个想法是,如果部署的服务使用的资源高于Manager上可用的资源,那么Manager应该保护资源超负荷(CPU,RAM,fds)的安全。它可以触发故障级联方案,并且集群可能变得非常不稳定(或不响应任何更多请求)。



其核心部分维护关键组件(如证书颁发和轮换,分布式数据存储,网络连接),因为管理员资源不足,使整个集群不稳定是不利的。



相关问题:





:我是Docker Swarm的维护者,并为Swarm模式撰写了管理指南


Say that we are working in swarm mode and we have three nodes:

  • manager1
  • worker1
  • worker2

Is it possible to create a service and specify that the tasks only has to run in the workers (worker1 and worker2) and not in the managers (manager1)

I am running the following command to create the service:

docker-machine ssh manager1 "docker service create --network dognet --name dog-db redis"

and when I ps the service:

docker-machine ssh manager1 "docker service ps dog-db"

I get:

ID                         NAME      IMAGE  NODE      DESIRED STATE  CURRENT STATE            ERROR
3kvfpbhl6fj0qwtglc5k7sbkw  dog-db.1  redis  manager1  Running        Preparing 4 seconds ago  

解决方案

While you can use constraints (with --constraint node.role=worker) to eliminate a subset of nodes based on their role (manager or worker), I would go as far as disabling the Manager(s) from acting like Worker(s) with:

# Disables the Manager as a Worker node

docker node update --availability drain manager1

The idea is that the Manager should be kept secure from resource overload (CPU, RAM, fds), that could happen if the resources used by deployed services is higher than the resources available on a Manager. It can trigger a failure cascade scenario and the cluster could become highly unstable (or not responding to any more requests).

The Manager, at its core, maintains critical components (like certificate issuance and rotation, distributed datastore, networking), it would be bad to make your entire cluster unstable because the Managers are running out of resources.

Related Issues:

Source: I was a maintainer of Docker Swarm and wrote the Administration Guide for Swarm mode.

这篇关于Docker群只在工作中运行任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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