GKE 集群节点上的 "allocatable cpu" 和 "allocated cpu limit" 有什么区别

What is the difference between "allocatable cpu" and "allocated cpu limit" on a GKE cluster node

当我做

kubectl describe node <node-name> | grep cpu

在我的 Google Kubernetes 集群上我得到

cpu:                        1
cpu:                        940m
cpu                        709m (75%)   2156m (229%)

我的问题是关于第二行最后一个数字 (940m) 和第三行最后一个数字 (2156m) 的区别。后者是分配资源的限制:

Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource                   Requests     Limits
  --------                   --------     ------
  cpu                        709m (75%)   2156m (229%)

前者是可分配的cpu

Allocatable:
 attachable-volumes-gce-pd:  128
 cpu:                        940m

这两个数字有什么区别?为什么它们不一样?决定 Pod 是否可以在节点上启动的相关限制是什么?

一言以蔽之

  • 940m 是您的 pod 使用的毫核数。
  • 2156m 是在因过度使用 CPU.
  • 而杀死您的 pod 之前可用的毫核数

更深入地说,它是架构的设计方式,当进程请求内存时,CPU 考虑机器的类型(裸机或云,以及哪个云)如何定义节点池以及这些节点池必须向 pods(部署集等)提供多少资源;这还考虑了开销和系统使用情况。

如果您想了解更多信息,我将添加到此答案的链接,以便您查看它们,它们非常有用。

祝你有愉快的一天!

[1] https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-architecture

[2] https://unofficial-kubernetes.readthedocs.io/en/latest/concepts/configuration/manage-compute-resources-container/

Allocatable 是可供 pods 消耗的资源量,在您的示例中为 940m cpu。

分配的限制是节点上 pods 运行 中定义的所有 pod 限制的总和。可分配和请求的资源更有用