×
Community Blog Enable cgroup V2 on Alibaba Cloud Container Service for Kubernetes

Enable cgroup V2 on Alibaba Cloud Container Service for Kubernetes

This article describes how to enable cgroup v2 on Alibaba Cloud Container Service for Kubernetes.

By Xining Wang

Kubernetes uses cgroups to isolate container resources. cgroup have two versions: v1 and v2. cgroup v2 offers a more consistent user experience and a broader range of features. For example, it supports extended Berkeley Packet Filter (eBPF) programs attached to cgroups, enabling resource monitoring and pod-based request redirects. Additionally, it serves as a dependency for eBPF-based network optimization. This article describes how to enable cgroup v2 on Alibaba Cloud Container Service for Kubernetes.

Prerequisites

1) Only Alibaba Cloud Linux 3.2104 and later versions support cgroup v2.

2) Ensure that the kernel version supports the cgroup v2 mechanism. You can check the version by running the following command:

grep cgroup /proc/filesystems

If the output includes the line "cgroup2", it means that the kernel version supports cgroup v2.

3) Enabling cgroup v2 requires configuration and adjustment in multiple aspects, so it needs to be handled with caution. In practical applications, it is recommended to conduct thorough testing first to ensure the stability and reliability of the application and system.

Procedures

1) Log on to each node and run the following command:

grubby --update-kernel=ALL --args=systemd.unified_cgroup_hierarchy=1

2) Confirm with the following command:

cat /etc/default/grub |grep systemd.unified_cgroup_hierarchy

It can be seen that the GRUB_CMDLINE_LINUX values include systemd.unified_cgroup_hierarchy=1.

3) You must restart the node.

4) After logging on to the node again, modify the kubelet startup configuration file /etc/systemd/system/kubelet.service.d/10-kubeadm.conf, manually disable a featuregate (--feature-gates=LocalStorageCapacityIsolation=false), and confirm that the parameters are modified as follows:

ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_SYSTEM_PODS_ARGS $KUBELET_DNS_ARGS $KUBELET_AUTHZ_ARGS $KUBELET_CGROUP_ARGS $KUBELET_CERTIFICATE_ARGS $KUBELET_EXTRA_ARGS $KUBELET_CUSTOMIZED_ARGS --feature-gates=LocalStorageCapacityIsolation=false --container-runtime=remote --container-runtime-endpoint=/var/run/containerd/containerd.sock

5) Reload the kubelet service configuration:

systemctl daemon-reload

6) Restart the kubelet service:

systemctl restart kubelet

Verify the Result

Confirm that cgroupv2 is Enabled

1) After you log on to the node again, determine whether to enable cgroupv2. Run the following command to view the cgroup controller list:

cat /sys/fs/cgroup/cgroup.controllers

Should return similar results:

cpuset cpu io memory hugetlb pids rdma

2) Run the following command to view the cgroup2 file system that is mounted on the current system:

mount |grep cgroup2

Should return similar results:

cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime)

3) Verify whether cgroup v2 is normal. You can use the following command to check whether cgroup v2 is running properly:

cat /sys/fs/cgroup/kubepods.slice/kubepods-besteffort.slice/cpu.max

If you can see a number that indicates CPU usage, it means that cgroup v2 has been enabled.

Confirm that kubelet is Running Properly

Check the kubelet running log to make sure that it is normal:

journalctl -u kubelet –f

Conclusion

The above steps outline the basic process of enabling cgroup v2 in Alibaba Cloud Container Service for Kubernetes (ACK). However, in real-world applications, additional configurations and adjustments may be required.

To summarize, enabling cgroup v2 involves configuring and adjusting multiple aspects, which should be approached with caution. It is recommended to conduct thorough testing in practical applications to ensure the stability and reliability of both the application and the system.

0 1 0
Share on

Xi Ning Wang(王夕宁)

56 posts | 8 followers

You may also like

Comments

Xi Ning Wang(王夕宁)

56 posts | 8 followers

Related Products