How Do I Check Whether a Pod Is Bound with vCPUs?
Take a node with 4 vCPUs and 8 GiB of memory as an example. Deploy a workload whose CPU request is 1 and limit is 2 in the cluster in advance.
- Log in to a node in the node pool and view the /var/lib/kubelet/cpu_manager_state output.
cat /var/lib/kubelet/cpu_manager_state
Information similar to the following will be displayed:
{"policyName":"static","defaultCpuSet":"0,2-3","entries":{"c1fcd22d-8a83-4aef-a27a-4c037e482b16":{"container-1":"1"}},"checksum":1500530529}
If the value of policyName is static, the policy has been configured.
- Check the cgroup setting of cpuset.preferred_cpus of the container. The output is the ID of the CPU that is preferentially used.
cat /sys/fs/cgroup/cpuset/kubepods/pod {pod uid} / {Container id} /cpuset.cpus
- {pod uid} indicates the pod UID. It can be obtained by running the following command on the host that has been connected to the cluster using kubectl:
kubectl get po {pod name} -n {namespace} -ojsonpath='{.metadata.uid}{"\n"}'
In the preceding command, {pod name} indicates the pod name and {namespace} indicates the namespace to which the pod belongs.
- {Container id} must be a complete container ID. To obtain the ID, run the following command on the node where the container is running:
Docker node pool: In the command, {pod name} indicates the pod name.
docker ps --no-trunc | grep {pod name} | grep -v cce-pause | awk '{print $1}'
containerd node pool: In the command, {pod name} indicates the pod name, {pod id} indicates the pod ID, and {container name} indicates the container name.
# Obtain the pod ID. crictl pods | grep {pod name} | awk '{print $1}' # Obtain the complete container ID. crictl ps --no-trunc | grep {pod id} | grep {container name} | awk '{print $1}'
A complete example is as follows:
cat /sys/fs/cgroup/cpuset/kubepods/podc1fcd22d-8a83-4aef-a27a-4c037e482b16/5cb15f55f429e4496172bef05994477caa96e0ca468563208695c1ad5cc141e0/cpuset.cpus
The command output shows that CPU 1 is bound.
1
- {pod uid} indicates the pod UID. It can be obtained by running the following command on the host that has been connected to the cluster using kubectl:
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot