简体   繁体   English

如何在 Kubernetes 中为 Pod 设置内存限制

[英]How to set Memory limit for a pod in Kubernetes

I have a node with 6gb memory.我有一个 6GB 内存的节点。 I want to run 2 pods on it.我想在上面运行 2 个 pod。

Question 1:问题 1:

在此处输入图片说明

POD1 have Request of 4GB and limits of 6GB and POD2 has no limit. POD1 有 4GB 的请求和 6GB 的限制,POD2 没有限制。
POD1 is working at 4GB and that leaves 2GB of memory free on node. POD1 以 4GB 运行,这在节点上留下了 2GB 的可用内存。
Can Kubernetes allocate POD2 in this node? Kubernetes 可以在这个节点分配 POD2 吗?
or will it be in Pending with You don't have enough resources ?还是会处于待定状态, You don't have enough resources

If Kubernetes run this Pod2 in this node, can POD2 grow into POD1's allocated 4GB memory??如果Kubernetes在这个节点上运行这个Pod2,POD2能长成POD1分配的4GB内存吗??
In other words, can Pod2 use memory allocated for Pod1??换句话说,Pod2 可以使用分配给 Pod1 的内存吗??

Question 2:问题2:
Will this setup(pic2) work?这个设置(图片2)会起作用吗?

在此处输入图片说明

The scheduler ensures that, for each resource type, the sum of the resource requests of the scheduled Containers is less than the capacity of the node.调度器确保对于每种资源类型,被调度的Container 的资源请求总和小于节点的容量。

If a Container exceeds its memory limit, it might be terminated.如果 Container 超过其内存限制,它可能会被终止。 If it is restartable, the kubelet will restart it, as with any other type of runtime failure.如果它是可重启的,kubelet 将重启它,就像任何其他类型的运行时故障一样。 If a Container exceeds its memory request, it is likely that its Pod will be evicted whenever the node runs out of memory.如果 Container 超过其内存请求,则每当节点内存不足时,它的 Pod 很可能会被驱逐。

Can Kubernetes allocate POD2 in this node? Kubernetes 可以在这个节点分配 POD2 吗?

Yes but only if it does not have requests more than 2GB.是的,但前提是它没有超过 2GB 的请求。

If Kubernetes run this Pod2 in this node, can POD2 grow into POD1's allocated 4GB memory??如果Kubernetes在这个节点上运行这个Pod2,POD2能长成POD1分配的4GB内存吗?? In other words, can Pod2 use memory allocated for Pod1??换句话说,Pod2 可以使用分配给 Pod1 的内存吗??

No.不。

Question 2: Will this setup(pic2) work?问题 2:此设置 (pic2) 会起作用吗?

The scheduler will schedule it.调度器会调度它。 But pod will be evicted if total memory consumption goes beyond the capacity of the node.但是如果总内存消耗超过节点的容量,pod 将被驱逐。

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

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