Kubernetes cgroup v2 Migration: What to Do Now

Daily Code Guide Kubernetes News

Kubernetes is moving its Linux resource-management foundation from cgroup v1 to cgroup v2. The change is not an immediate claim that cgroup v1 has been completely removed: Kubernetes documents cgroup v1 as deprecated since version 1.35, while the removal plan says code removal will occur no earlier than Kubernetes v1.38.

For platform teams, the practical concern is closer than the final removal date. The kubelet does not start by default on a cgroup v1 node under the documented behavior, and nodes, runtimes, monitoring agents, and applications may all need compatibility work before an upgrade.

What changed in Kubernetes cgroup support?

Kubernetes documentation describes cgroup v2 as stable since Kubernetes v1.25. Cgroup v1 is deprecated since v1.35, and the kubelet will no longer start on a cgroup v1 node by default. Administrators can explicitly set failCgroupV1 to false in the kubelet configuration to retain startup on cgroup v1, but that should be treated as a compatibility override rather than a long-term direction for cluster design.

The Kubernetes Enhancement Proposal for removing cgroup v1 describes a phased transition and eventual code removal. It does not establish a definitive final release or date; it states only that removal will occur no earlier than Kubernetes v1.38. Teams should therefore plan for migration without presenting v1.38 as a guaranteed completion point.

This is primarily a node and workload compatibility change, not an API-object migration. Existing applications may continue to use the Kubernetes API normally, but the software that measures resource limits or reads the cgroup filesystem must understand the cgroup v2 interface.

Ad

Check the node and runtime prerequisites

A cgroup v2 migration requires more than changing one kubelet setting. Kubernetes lists these baseline requirements:

  • A Linux distribution that enables cgroup v2.
  • Linux kernel 5.8 or later.
  • A container runtime that supports cgroup v2, including the documented containerd 1.4+ and CRI-O 1.20+ versions.
  • Matching cgroup-driver settings between the kubelet and container runtime.

On a Linux node, the cgroup version can be checked with:

stat -fc %T /sys/fs/cgroup/

The output cgroup2fs indicates cgroup v2, while tmpfs indicates cgroup v1. This check should be part of node inventory before an upgrade, alongside the operating system, kernel, kubelet configuration, runtime version, and runtime cgroup-driver setting.

For distributions using systemd as the init system, Kubernetes recommends the systemd cgroup driver. The kubelet and runtime must use compatible settings; a mismatch can prevent the node from operating correctly. The container runtime guidance explains the driver requirement and runtime considerations.

What kubeadm administrators should review

In kubeadm clusters, the cgroup-driver documentation says kubeadm defaults the cgroup driver to systemd when it is unspecified in Kubernetes v1.22 and later. Kubeadm also uses the same KubeletConfiguration across nodes, with configuration represented in the kubeadm configuration and node-local kubelet settings.

That does not make an in-place driver change risk-free. Kubernetes warns that changing the cgroup driver on a node that has already joined a cluster can cause Pod sandbox recreation errors. Where practical, replacing nodes is safer operationally. If an in-place migration is necessary, it should be controlled one node at a time: drain the node, stop and reconfigure the runtime and kubelet as required, restart services, and validate node and workload health before proceeding.

The kubelet normally detects cgroup v2 automatically and does not require additional kubelet configuration solely to use it. The important configuration work is ensuring that the operating system, runtime, kubelet, and any node software agree on the cgroup version and driver.

Workload and tooling compatibility matters

Applications and agents that directly inspect cgroup files are the most obvious migration risk. Standalone monitoring deployments, security agents, cAdvisor installations, and software that reads memory limits may need updates for the cgroup v2 API.

Teams should also review runtimes and libraries that derive process limits from cgroup data. The Kubernetes guidance specifically calls out Java, Node.js, and automaxprocs-related versions as items to review when they depend on cgroup-derived resource limits. Standalone cAdvisor deployments should be updated to version 0.43.0 or later where applicable.

A program that reads the wrong cgroup path or interprets a cgroup v2 value using cgroup v1 assumptions can be incorrectly sized. That may result in a process believing it has more or less memory or CPU capacity than its container actually has. This is a compatibility concern, not evidence of a general security guarantee or security flaw associated with either cgroup version.

Memory QoS changes the operational picture

Cgroup v2 also enables Kubernetes memory-management features that are not available through cgroup v1. Memory QoS uses cgroup v2 memory-controller features and is documented as beta and enabled by default since Kubernetes v1.37.

Memory QoS can provide memory throttling and protection through kubelet configuration fields such as memoryThrottlingFactor and memoryReservationPolicy. The documentation gives 0.9 and TieredReservation as example values. Teams should evaluate these settings against actual workload limits and memory behavior rather than applying them without testing.

Memory QoS requires Linux with cgroup v2. Kubernetes recommends kernel 5.9 or later for this feature because older kernels can encounter a known memory.high livelock issue. Workloads using tiered memory protection also need sufficient page-cache headroom; insufficient headroom can contribute to OOM kills for some Guaranteed workloads.

What you should do before upgrading

  1. Inventory every node. Record the cgroup version, Linux distribution, kernel version, kubelet configuration, runtime version, and runtime cgroup driver. Use the filesystem check to identify cgroup v1 and v2 nodes.
  2. Align the cgroup drivers. On systemd-based distributions, plan for the recommended systemd driver and verify that the kubelet and runtime match.
  3. Test node replacement or staged migration. Prefer replacing nodes where feasible. For in-place changes, drain and migrate one node at a time, then validate scheduling, Pod sandboxes, node readiness, and workload behavior.
  4. Audit agents and applications. Confirm cgroup v2 support for monitoring, security, cAdvisor, language runtimes, and any software that reads cgroup files or memory limits.
  5. Review memory behavior. If using Memory QoS, use a kernel version that meets the documented recommendation and test throttling, protection, page-cache use, and OOM behavior with representative workloads.
  6. Make kubeadm settings explicit. Check the shared KubeletConfiguration and node-local configuration so new and existing nodes do not diverge.

Availability and migration caveats

Cgroup v2 is already stable in Kubernetes, and Memory QoS is beta and enabled by default from v1.37. The cgroup v1 deprecation is also already documented, but complete removal is not yet assigned to a definitive Kubernetes release. The only committed timing in the cited removal proposal is that removal will occur no earlier than v1.38.

Distribution-specific procedures are not identical, and the documented kubeadm guidance is a Kubernetes v1.36 snapshot rather than universal instructions for every Kubernetes release. Treat the migration as a compatibility project spanning the node image, kernel, runtime, kubelet, agents, and workloads—not as a single configuration toggle.

Sources

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Ad
Ad
Ad