Get the App
SLTechnology News&Howtos  ›  Servers  › 

K8S Cpu-Manager-Policy

Shulou Source: shulou.com Published: 2022-06-03 07:14:50 11月14日 Update

Note: K8S version 1.10

During the use of K8S, it is found that the java program starts very slowly, which is mainly due to the low CPU utilization caused by the frequent switching of K8S CPU context. This problem can be solved through the cpu-manager-policy of K8S, configured as follows.

Add the following parameters to the startup parameters of kubelet:

-feature-gates=CPUManager=true-cpu-manager-policy=static-kube-reserved=cpu=1,memory=0

Restart kubelet

Systemctl restart kubelet

Find an error report

Jan 23 10:49:30 sh-saas-k8s1-node-dev-02 systemd: Starting Kubernetes systemd probe.

Jan 23 10:49:30 sh-saas-k8s1-node-dev-02 kubelet: panic: [cpumanager] state file: unable to restore state from disk (policy configured "static"! = policy from state file "none")

Jan 23 10:49:30 sh-saas-k8s1-node-dev-02 kubelet: Panicking because we cannot guarantee sane CPU affinity for existing containers.

Jan 23 10:49:30 sh-saas-k8s1-node-dev-02 kubelet: Please drain this node and delete the CPU manager state file "/ data/kubernetes/kubelet/cpu_manager_state" before restarting Kubelet.

Jan 23 10:49:30 sh-saas-k8s1-node-dev-02 kubelet: goroutine 1 [running]:

This is because kubelet has a state file, follow the above to find that file, and manually change the status to static.

Restart kubelet to set the limit and request for high-performance applications to the same, and the number of cpu must be an integer, so that K8S will automatically bind the application to cpu, resulting in a great improvement in performance.

Tags: Number parameters files applications frequency up and down context utilization reason can pass performance situation manual integer version state program process problem face Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Microsoft Redmi Xiaomi Apple