How can I enable both cgroups v1 and v2?

Follow
Table of Contents

Question

As more recent and modern distributions update their kernel configurations, sometimes the default for cgroups will show as Version 2, instead of the well-established and standardized Version 1, as seen in the docker info output below. How can an administrator modify this behavior?

...
Logging Driver: json-file       
Cgroup Driver: systemd          
Cgroup Version: 2               
Plugins:                        
 Volume: local                  
...

Answer

A special kernel paramater systemd.unified_cgroup_hierarchy=0 will allow for both V1 and V2 versions of cgroups, with the default as Version 1. Without the parameter change, Docker containers may fail to start. Enabling hybrid support in this manner can ensure compatibility as the industry transitions between both versions.

Pre-requisites

  • Kubernetes cluster nodes using current distributions with newer kernels

Enable both CGroups V1 and V2 with the kernel option

Modify your distribution's kernel commandline options, then run the appropriate update for your boot loader.

sudo sed -i '/^GRUB_CMDLINE_LINUX/ s/"$/ systemd.unified_cgroup_hierarchy=0"/' /etc/default/grub

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

After rebooting, check that the kernel parameter was added with cat /proc/cmdline and output of docker info, verifies that it shows Cgroup Version: 1.

More Information

CGroups V1 & V2 Hybrid for RKE2

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.