Cgroup drivers:systemd cgroupfs 区别

通过下面内容可知:systemd和cgroupfs都是CGroup管理器,而systemd是大多数Linux发行版原生的。如果Docker运行时和kubelet的CGroup驱动配置为cgroupfs,则意味着使用了systemd作为init system的系统上有两个不同的CGroup管理器。

When systemd is chosen as the init system for a Linux distribution, the init process generates and consumes a root control group (cgroup) and acts as a cgroup manager. Systemd has a tight integration with cgroups and allocates a cgroup per systemd unit. It's possible to configure your container runtime and the kubelet to use cgroupfs. Using cgroupfs alongside systemd means that there will be two different cgroup managers.

当选择systemd作为Linux发行版的init system时,init process生成并使用一个root控制组(cgroup),并充当cgroup管理器。Systemd与cgroups紧密集成,并为每个Systemd Unit分配一个cgroup。可以将容器runtime 和kubelet配置为使用cgroupfs。与systemd一起使用cgroupfs意味着将有两个不同的cgroup管理器。


A single cgroup manager simplifies the view of what resources are being allocated and will by default have a more consistent view of the available and in-use resources. When there are two cgroup managers on a system, you end up with two views of those resources. In the field, people have reported cases where nodes that are configured to use cgroupfs for the kubelet and Docker, but systemd for the rest of the processes, become unstable under resource pressure.


可以通过修改docker的/etc/docker/daemon.json文件,更改docker和kubelet的CGroup Driver:

"exec-opts": ["native.cgroupdriver=systemd"]

查看kubelet --help 提示,默认的是cgroupfs,所以除了修改docker的配置,kubelet的配置也要修改,否则通过kubelet调度的容器将无法运行!

--cgroup-driver string Driver that the kubelet uses to manipulate cgroups on the host. Possible values: 'cgroupfs', 'systemd' (default "cgroupfs")


cgroupDriver: systemd

Changing the settings such that your container runtime and kubelet use systemd as the cgroup driver stabilized the system. To configure this for Docker, set native.cgroupdriver=systemd.