我在k8s (AKS,k8s版本1.19.7)上用cpu="6"和memory=20G创建了一个Pod (参见下面的配置)。因此,当我在k8s docu上阅读时,我期望Pod在CPU上有6个核心。
一个cpu (以Kubernetes为单位)相当于云提供商的1 vCPU/Core
当我检查容器上的lscpu时,我得到
root@user-ubuntu:/# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 46 bits physical, 48 bits virtual
CPU(s): 16 <-- 2x 8 hyperthreading cores?
On-line CPU(s) list: 0-15
Thread(s) per core: 2
Core(s) per socket: 8 <-- expected 6
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 85
Model name: Intel(R) Xeon(R) Platinum 8168 CPU @ 2.70GHz 而且,内存似乎是32G而不是20G。
root@user-ubuntu:/# vmstat -s -S M
32114 M total memorykind: Pod
apiVersion: v1
metadata:
name: user-ubuntu
spec:
containers:
- name: user-ubuntu
image: ubuntu:latest
command: ["/bin/sleep", "3650d"]
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: "6"
memory: 20G
limits:
cpu: "6"
memory: 20G
volumeMounts:
- mountPath: "/mnt/azure"
name: volume
restartPolicy: Always
volumes:
- name: volume
persistentVolumeClaim:
claimName: pvc-user-default发布于 2021-07-28 07:00:27
lscpu命令显示内核资源,特别是来自/proc/cpuinfo的内核资源(参见文档)。现在,在主机系统(可以是物理机器或VM)上运行的所有容器都共享同一个内核(这是容器与VM的区别)。因此,从lscpu获得的信息对应于底层主机,而不是容器。
下面是讨论这个问题的参考文献列表:
但是,容器受到C组的限制,仅限于在Pod定义中定义的资源使用。因此,即使lscpu显示16个核心,您的容器仍然只能使用其中的6个。内存也是如此。
https://stackoverflow.com/questions/68555594
复制相似问题