In the cgroupv2 environment, kubectl top node cannot obtain the utilization of cpu and memory – kubernetes/kubernetes
Table of Contents
What happened?
In the cgroupv2 environment,kubectl top node cannot obtain the utilization of cpu and memory.
use
NODE_NAME=<Name of node in your cluster>
kubectl get --raw /api/v1/nodes/$NODE_NAME/proxy/metrics/resource
and
NODE_NAME=<Name of node in your cluster>
kubectl get --raw /api/v1/nodes/$NODE_NAME/proxy/stats/summary
both got value of 0.
Continue to analyze, when the cpu.stat of the root directory is obtained for cadivisor, the file does not exist and reports an error.
err="open /sys/fs/cgroup/cpu.stat: no such file or directory"
There is no cpu.stat file in the root directory of the environment. Is this the expected behavior, or is there a configuration error?
What did you expect to happen?
kubectl top node gets data normally
How can we reproduce it (as minimally and precisely as possible)?
Install and deploy metrics-server in an environment where cgroupv2 is enabled to obtain node resource utilization
Anything else we need to know?
No response
Kubernetes version
“`console
$ kubectl version
# paste output here
kubelet –version=raw
version.Info{Major:”1″, Minor:”25+”, GitVersion:”v1.25.0-alpha.2.625+0532324bd17c58-dirty”, GitCommit:”0532324bd17c58cd052da8c62a24ae8804167549″, GitTreeState:”dirty”, BuildDate:”2022-08-01T15:00:53Z”, GoVersion:”go1.18.1″, Compiler:”gc”, Platform:”linux/amd64″}
“`
Cloud provider
OS version
“`console
# On Linux:
$ cat /etc/os-release
# paste output here
NAME=”Ubuntu”
VERSION=”20.04.3 LTS (Focal Fossa)”
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME=”Ubuntu 20.04.3 LTS”
VERSION_ID=”20.04″
HOME_URL=”https://www.ubuntu.com/”
SUPPORT_URL=”https://help.ubuntu.com/”
BUG_REPORT_URL=”https://bugs.launchpad.net/ubuntu/”
PRIVACY_POLICY_URL=”https://www.ubuntu.com/legal/terms-and-policies/privacy-policy”
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
$ uname -a
# paste output here
Linux ubuntu 5.4.0-81-generic #91-Ubuntu SMP Thu Jul 15 19:09:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
“`
Install tools
Container runtime (CRI) and version (if applicable)
curl -v --unix-socket /var/run/crio/crio.sock http://localhost/info | jq
* Trying /var/run/crio/crio.sock:0...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to localhost (/var/run/crio/crio.sock) port 80 (#0)
> GET /info HTTP/1.1
> Host: localhost
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Tue, 02 Aug 2022 01:42:54 GMT
< Content-Length: 239
<
{ [239 bytes data]
100 239 100 239 0 0 233k 0 --:--:-- --:--:-- --:--:-- 233k
* Connection #0 to host localhost left intact
{
"storage_driver": "overlay",
"storage_root": "/var/lib/containers/storage",
"cgroup_driver": "systemd",
"default_id_mappings": {
"uids": [
{
"container_id": 0,
"host_id": 0,
"size": 4294967295
}
],
"gids": [
{
"container_id": 0,
"host_id": 0,
"size": 4294967295
}
]
}
}
Related plugins (CNI, CSI, …) and versions (if applicable)
Read more here: Source link