如果容器不与主机共享内核,解析 cgroup 文件是否可行?

Is parsing cgroup files for stats viable if the container is not sharing the kernel with host?

在主机上的 cgroup 文件中找到的统计信息,如果容器不与主机共享内核,它们是否可靠?

我问这个是因为虽然它在 docker 上很可靠,但 K8s 支持多个运行时 - 有些提供带有自己内核的容器,我应该依赖运行时守护进程来获取统计信息还是可以我绕过它们,仍然查看 cgroup 文件。

如果您指的是 Kata Containers with Docker 和 Kubernetes,简短的回答是肯定的。确保配置 sandbox_cgroup_only=true 以获得准确的统计数据。

此外,请确保使用 Kata Containers 1.11.0 或更高版本 the cgroups implementation fix went into that version. Kata Containers creates its own cgroups in the Kernel running in the VM but that matches what's created at the host level. The resources for these cgroups created at the host level are not used, but rather the resources allocated by the VMM. Some more info here