简体   繁体   English

Kubernetes Pod N:M调度方法

[英]Kubernetes pods N:M scheduling how-to

Batch computations, Monte Carlo, using Docker image, multiple jobs running on Google cloud and managed by Kubernetes. 批处理计算,蒙特卡洛(Monte Carlo),使用Docker映像,在Google云上运行并由Kubernetes管理的多个作业。 No Replication Controllers, just multiple pods with NoRestart policy delivering computed payloads to our server. 没有复制控制器,只有具有NoRestart策略的多个Pod将计算的有效负载传递到我们的服务器。 So far so good. 到现在为止还挺好。 Problem is, I have cluster with N nodes/minions, and have M jobs to compute, where M > N . 问题是,我有N节点/小兵的集群,并且有M个作业要计算,其中M > N So I would like to fire M pods at once and tell Kubernetes to schedule it in such a way so that only N are running at a given time, and everything else is kept in Pending state. 因此,我想立即触发M Pod,并告诉Kubernetes以这样的方式调度它,以便在给定的时间仅N正在运行,而其他所有都保持为Pending状态。 As soon as one pod is done, next is scheduled to run moving from Pending to Running and so on and so forth till all M pods are done. 一旦完成一个Pod,就计划将下一个Pod从Pending转到Running,依此类推,以此类推,直到完成所有M Pod。

Is it possible to do so? 有可能这样做吗?

Yes, you can have them all ask for a resource of which there's only one on each node, then the scheduler won't be able to schedule more than N at a time. 是的,您可以让他们都要求一个资源,每个节点上只有一个资源,那么调度程序一次将不能调度N个以上的资源。 The most common way to do this is to have each pod ask for a hostPort in the ports section of its containers spec. 最常见的方法是让每个Pod在其containers规范的ports部分中要求一个hostPort

However, I can't say I'm completely sure why you would want to limit the system to one such pod per node. 但是,我不能完全确定为什么您要将系统限制为每个节点一个这样的Pod。 If there are enough resources available to run multiple at a time on each node, it should speed up your job to let them run. 如果有足够的资源可在每个节点上一次运行多个资源,则应加快您的工作速度,使其运行。

Just for the record, after discussion with Alex, trial and error and a binary search for a good number, what worked for me was setting the CPU resource limit in the Pod JSON to: 仅作记录,在与Alex讨论,反复试验和对好的数字进行二进制搜索之后,对我有用的是将Pod JSON中的CPU资源限制设置为:

    "resources": {
        "limits": {
            "cpu": "490m"
        }
    }

I have no idea how and why this particular value influences the Kubernetes scheduler, but it keeps nodes churning through the jobs, with exactly one pod per node running at any given moment. 我不知道这个特定的值如何以及为什么会影响Kubernetes调度程序,但是它使节点一直在运行任务,每个节点在任何给定时刻都只有一个Pod在运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM