Kubernetes源码分析之CPU Manager
背景 Kubelet默认使用CFS Quota/Share的方式来实现Pod的CPU层面约束,而对于cpuset的支持,通过很长一段时间的讨论([Issue] Determine if we should support cpuset-cpus and cpuset-mem)后,最终通过CPU Manager来实现。
CPU Manager作为alpha版本从v1.8开始出现,自v1.10开始作为beta版本默认开启。
使用方式 v1.10版本前需要开启feature-gate。
--feature-gates=CPUManager=true 开启cpuset还需要一些cpumanager的参数设置
--cpu-manager-policy=static --cpu-manager-reconcile-period=10s / Optional, default same as `--node-status-update-frequency` 还需要设置cpu reservation,可以通过
--kube-reserved // or --system-reserved 源码分析 Start CPU Manager 在kubelet启动之时,cpuManager会被生成,并Start。此时,cpuManager已经获取了所在宿主机的cpu拓扑结构,并且另起goroutine每隔reconcilePeriod时间,对宿主机上所有的activePods做一次reconcile。
kubelet.go
// initializeModules will initialize internal modules that do not require the container runtime to be up. // Note that the modules here must not depend on modules that are not initialized here.
[Read More]