Kubernetes:Pod scheduling/eviction 与 requests/limits 的关系

Kubernetes : Pod scheduling/eviction relationship with requests/limits

如果我有一个具有 16 GB RAM 和 pods 的节点,其内存请求为 1GB,内存限制为 4GB,那么节点上将安排多少 pods? 4 还是 16?

据此我认为是 16 https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/

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.

如果 pod 开始使用在其限制范围内的 4GB 内存,它会被驱逐吗?重新安排?

我有一个用例,我的 pods 通常会使用 X 内存,但有时会使用 4X 内存。我应该如何设置我对这种情况的要求和限制?我应该将请求设置为 X 还是 4X?

Kubernetes 调度程序应该能够将 16 个 pods 每个具有 1GB 内存请求的节点调度到一个可用容量为 16GB 内存的节点。如果在任何时间点任何 pod 开始使用更多内存(在限制范围内)它将被允许这样做。但是当总内存消耗超出节点的容量时,消耗超过其请求的 pods 将随机终止并重新安排,除非有优先级,在这种情况下,较低优先级 pods 将成为受害者.

Requests:这个值用于调度。这是容器需要的最小资源量 运行。请注意,请求并不意味着这些始终是容器的专用资源。

限制:这是节点将允许容器使用的此资源的最大数量。

https://sysdig.com/blog/kubernetes-pod-evicted/

First, kubelet tries to free node resources, especially disk, by deleting dead pods and its containers, and then unused images. If this isn’t enough, kubelet starts to evict end-user pods in the following order:

  • 尽力而为。
  • Burstable pods 使用的资源多于其对资源匮乏的请求。
  • Burstable pods 使用的资源少于其对匮乏资源的请求。

If a Container exceeds its memory limit, it might be terminated. If it is restartable, the kubelet will restart it, as with any other type of runtime failure.

If a Container exceeds its memory request, it is likely that its Pod will be evicted whenever the node runs out of memory.

https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/

A Container can exceed its memory request if the Node has memory available.

But a Container is not allowed to use more than its memory limit. If a Container allocates more memory than its limit, the Container becomes a candidate for termination. If the Container continues to consume memory beyond its limit, the Container is terminated

https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/