You provision a new node pool on RHEL 9 or Ubuntu 22.04. The cluster joins, pods schedule, and everything looks 1/1 Ready. But your custom Prometheus dashboards for container memory go blank. Your older Java apps start randomly OOMing.
What happened? Your cluster just upgraded to Linux cgroups v2.
If you keep up with my blog, you know I prefer debugging from the filesystem over guessing from a dashboard. That is also why the CLI and console disagree on node memory. The shift from cgroup v1 to v2 completely rewrites that filesystem. Here is exactly what changed, why it matters for your workloads, and what you need to fix before upgrading.
The Timeline
Cgroups v1 was merged into the Linux kernel in 2008, bringing containerization to life. But it was messy. Cgroups v2 was completely rewritten and declared stable in Linux 4.5 back in 2016 to fix those messes.
However, the Kubernetes ecosystem moved slowly. Kubernetes officially added v2 support in v1.19, made it Generally Available in 1.25, and has now formally deprecated cgroup v1. If you run a modern OS like RHEL 9, Fedora, or Ubuntu 22.04, v2 is now the default.
Why v1 Was Flawed
Under v1, every resource controller lived in its own directory tree. A container had one path for CPU (/sys/fs/cgroup/cpu) and a completely separate path for memory (/sys/fs/cgroup/memory).
This fragmentation broke cross-resource tracking. If a process was writing heavily to disk and filling up memory with page cache, the kernel couldn't cleanly link the I/O operations back to the memory controller to throttle it properly.
The v2 Fix: Unified Hierarchy
Cgroups v2 uses a single, unified tree under /sys/fs/cgroup/. A process sits in one leaf directory, and all resource controls apply there.
Unified Hierarchy:
Under cgroups v1, you had multiple hierarchies: cpu, cpuacct, memory, blkio, etc. Each had its own tree structure under /sys/fs/cgroup/.
- CPU:
/sys/fs/cgroup/cpu/pod1 - Memory:
/sys/fs/cgroup/memory/pod1 - Blkio:
/sys/fs/cgroup/blkio/pod1
This led to several problems:
- Complex Management: You needed to configure each controller separately.
- Resource Isolation Issues: You couldn't guarantee that the CPU controller's view of the process matched the memory controller's view.
- Cross-Resource Tracking: It was difficult to correlate resource usage across different controllers.
cgroup v1: Multiple Trees per Controller
/sys/fs/cgroup/├── cpu/ # CPU controller tree│ └── kubepods/│ └── pod_<UUID>/│ ├── cpu.cfs_quota_us│ ├── cpu.cfs_period_us│ ├── cpu.shares│ └── tasks├── memory/ # Memory controller tree│ └── kubepods/│ └── pod_<UUID>/│ ├── memory.limit_in_bytes│ ├── memory.usage_in_bytes│ ├── memory.oom_control│ └── tasks├── blkio/ # I/O controller tree│ └── kubepods/│ └── pod_<UUID>/│ ├── blkio.throttle.read_bps_device│ ├── blkio.throttle.write_bps_device│ └── tasks└── pids/ # Process count controller tree └── kubepods/ └── pod_<UUID>/ ├── pids.max └── tasksCgroups v2 unifies all controllers into a single hierarchy:
/sys/fs/cgroup/├── cgroup.controllers # Available controllers on host (cpu memory io pids)├── cgroup.subtree_control # Controllers delegated to child slices├── cgroup.procs└── kubepods.slice/ # Single unified tree for all controllers ├── cgroup.controllers ├── cgroup.subtree_control └── pod_<UUID>.slice/ # All resource controls live together ├── cgroup.procs # Process IDs in this pod ├── cpu.max # CPU quota & period in one file ├── cpu.weight # Proportional CPU weight ├── memory.max # Hard OOM limit (replaces memory.limit_in_bytes) ├── memory.high # Memory throttle threshold (new in v2) ├── memory.current # Current usage (replaces memory.usage_in_bytes) ├── memory.events # OOM and reclaim counters ├── io.max # Block I/O rate limits └── pids.max # Process limitThis architecture enables three major features:
- No More Instant OOM Kills: In v1, memory limits were a hard cliff (
memory.limit_in_bytes). Cross it, and the kernel immediately terminated the process. v2 introduces a multi-gate system. Instead of a single limit, you get memory.max (the hard limit) and memory.high. When a container crosses memory.high, the kernel doesn't kill it. It aggressively slows down the threads asking for memory and forces the system to reclaim pages. Your pod stays running, just throttled. - Real Pressure Metrics (PSI): Before v2, figuring out if a node was actually starved for resources meant guessing based on CPU utilization percentages. v2 introduces Pressure Stall Information (PSI). The kernel tracks exactly how much time threads spend stalled waiting for CPU, memory, or I/O. If you read memory.pressure inside a container's cgroup and the some or full values are zero, your workload isn't starved, regardless of what a dashboard says.
- Accurate Page Cache Writeback: Because memory and I/O are in the same tree, the kernel finally knows exactly which container is generating disk writebacks. It can throttle noisy neighbors before they exhaust disk IOPS for the rest of the node. When the storage backend itself stops responding, the same I/O path can wedge processes in uninterruptible sleep, a failure mode covered in debugging D-state processes on worker nodes.
What Breaks When You Upgrade
You can't just flip the switch to v2 without auditing your workloads.
- Older Runtimes Go Blind
Older versions of Java, Node.js, and .NET hardcode the v1 /sys/fs/cgroup/memory paths to figure out how much RAM they have. On a v2 node, those files don't exist.
The runtime assumes it has access to the entire host's physical RAM, sizes its heap massively, blows past the Kubernetes pod limit, and gets killed (you can still inspect the crash trace by checking where restarted pod logs are stored on the worker node).
The fix: Upgrade to v2-aware versions (JDK 11.0.16+, Node.js 20.3.0+). If you can't upgrade the base image, explicitly hardcode your heap limits (e.g., -Xmx).
- Custom Scripts Return 404s
If your bash scripts or legacy monitoring agents read memory.usage_in_bytes or cpu.cfs_quota_us, they will fail. The file names changed. For example, memory usage is now memory.current.
The fix: Audit internal tooling and upgrade agents like cAdvisor to natively handle v2 paths.
- The Systemd Cgroup Driver
Modern Kubernetes deployments strongly recommend using systemd as the cgroup driver instead of cgroupfs. Ensure your kubelet and containerd config files explicitly set SystemdCgroup = true to prevent two different managers from fighting over the same cgroup tree.
Verification
Never guess which version your node is running. SSH into a worker node and check the filesystem:
stat -fc %T /sys/fs/cgroup/- cgroup2fs: You are running v2.
- tmpfs: You are still on legacy v1.