gpt4 book ai didi

Kubernetes:Pod 和 CPU 限制

转载 作者:行者123 更新时间:2023-12-02 11:36:44 26 4
gpt4 key购买 nike

为了这个问题,我们假设如下:

  • 我的 Kubernetes 集群上总共有 12 个 CPU
  • 这 12 个 CPU 分布在 3 个节点上。
  • 我在集群上运行单个 pod,没有指定任何 CPU 资源信息。在那种情况下,我认为 CPU 请求的默认值是 100m(单个 CPU 的 10%)。
  • pod 处于副本硬编码为 1 且未定义自动缩放的部署中。

据我了解,这意味着单个 pod 将仅在 3 个集群节点之一上运行,因为单个节点可以轻松满足其请求 CPU。然而,pod 开始处理一些非常 CPU 密集型的事情,这让集群“感到惊讶”。

会发生什么?

由于没有为 pod 设置“限制”,Kubernetes 是否会允许该 pod 在该单个主机节点上使用更多 CPU?到什么限度?节点的 CPU 限制?一些任意的默认限制?

我的问题只涉及 CPU 资源,不涉及内存。

最佳答案

每个节点对于每种资源类型都有一个最大容量:它可以为 Pod 提供的 CPU 和内存量,因此如果它超过主机限制,它肯定会被终止。

If you do not specify a CPU limit for a Container, then one of these situations applies:

1) The Container has no upper bound on the CPU resources it can use. The Container could use all of the CPU resources available on the Node where it is running.

2) The Container is running in a namespace that has a default CPU limit, and the Container is automatically assigned the default limit. Cluster administrators can use a LimitRange to specify a default value for the CPU limit.

Describe 命令将为您提供有关工作节点的所有详细信息

$ kubectl describe nodes k8s-node01
Name: k8s-node01
Roles: <none>
Labels: beta.kubernetes.io/arch=amd64

Taints: <none>
Unschedulable: false

Capacity:
cpu: 4
ephemeral-storage: 40593708Ki
hugepages-1Gi: 0
hugepages-2Mi: 0
memory: 16432224Ki
pods: 110
Allocatable:
cpu: 4
ephemeral-storage: 37411161231
hugepages-1Gi: 0
hugepages-2Mi: 0
memory: 16329824Ki
pods: 110
System Info:
Machine ID: 15b4b4728a454166acafff508d4022e8
System UUID: 15B4B472-8A45-4166-ACAF-FF508D4022E8
Boot ID: bf52803c-9123-49e2-967b-2585401f958f
Kernel Version: 4.4.0-169-generic
OS Image: Ubuntu 16.04.6 LTS
Operating System: linux
Architecture: amd64
Container Runtime Version: docker://19.3.4
Kubelet Version: v1.17.2
Kube-Proxy Version: v1.17.2
PodCIDR: 192.168.1.0/24
PodCIDRs: 192.168.1.0/24
Non-terminated Pods: (3 in total)
Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits AGE
--------- ---- ------------ ---------- --------------- ------------- ---
kube-system calico-node-j45l6 250m (6%) 0 (0%) 0 (0%) 0 (0%) 7h1m
kube-system kube-proxy-7w5fc 0 (0%) 0 (0%) 0 (0%) 0 (0%) 7h1m
mynamespace nginx 0 (0%) 0 (0%) 0 (0%) 0 (0%) 33m
Allocated resources:
(Total limits may be over 100 percent, i.e., overcommitted.)
Resource Requests Limits
-------- -------- ------
cpu 250m (6%) 0 (0%)
memory 0 (0%) 0 (0%)
ephemeral-storage 0 (0%) 0 (0%)
Events: <none>

关于Kubernetes:Pod 和 CPU 限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60079822/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com