简体   繁体   English

Kubernetes中Pod的资源分配

[英]Resource allocation to pods in Kubernetes

Assume that Kubernetes has scheduled two pods A and B in a node N. If the resource capacity of the Node N is (30 CPU, 70 Memory) and pod A requests (5 CPU, 8 memory) and pod B requestes (4 CPU, 10 memory), is it possible to share the resources among two pods in a way that we maintain the efficieny of the cluster and maximize the allocation of pods? 假设Kubernetes在节点N中调度了两个Pod A和B.如果Node N的资源容量为(30 CPU,70 Memory),并且Pod A请求(5 CPU,8 Memory)和Pod B Requestes(4 CPU, 10个内存),是否有可能以我们维持集群效率并最大化Pod分配的方式在两个Pod之间共享资源? How can I change the codes to achieve this? 如何更改代码以实现此目的? Assuming that each pod maintains 1 container. 假设每个吊舱维护1个容器。

Kubernetes already does that. Kubernetes已经做到了。

Resource Requests are soft reservations, that means, the scheduler will consider it as a requirement when placing the pod in the node, it will allocate the resource to a POD but won't reserve the resources to be used exclusively by the pod that requested it. 资源请求是软预留,这意味着调度程序将pod放置在节点中时将其视为必需条件,它将资源分配给POD,但不会保留供请求它的pod专用的资源。 。

If the POD request 1Gb of memory and consumed only 500Mb, other pods will be able to consume the remainder. 如果POD请求1Gb内存并且仅消耗500Mb,则其他Pod将能够消耗剩余的空间。

The main issue is when other PODs does not set limits, this will prevent the scheduler of controlling the load properly and other running pods might affect the pod. 主要问题是,当其他POD未设置限制时,这将阻止调度程序正确控制负载,而其他正在运行的Pod可能会影响Pod。 Other issue is when Limits are set too high and when being consumed will reach the node capacity. 另一个问题是,当限制设置得太高并且消耗时将达到节点容量。

To have a proper balance and efficiency, requests and limits should be set appropriately and prevent over-commitment. 为了获得适当的平衡和效率,应该适当设置请求和限制,并防止过度承诺。

This other SO shows a nice example of it: Allocate or Limit resource for pods in Kubernetes? 其他SO展示了一个很好的示例: 在Kubernetes中分配或限制Pod的资源?

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

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