Migrating to cgroups v2 in GKE: A Tale of Clusters and Containers

Nikhil Naidu
3 min readMar 19, 2025

--

Hey there, fellow cloud adventurer! If you’re running a Google Kubernetes Engine (GKE) cluster — like my trusty gke-test-cluster-dev in the chilly northamerica-northeast1 region — you might’ve heard the whispers: cgroups (control groups) v2 is the new kid on the block, and it’s time to move on from the old cgroups v1 ways. Don’t worry if that sounds like tech gibberish; I’m here to walk you through this migration with a grin, a coffee, and some step-by-step goodness. Let’s dive into the wild world of resource management and make our cluster the coolest in town!

Why Bother with cgroups v2?

Picture this: cgroups (control groups) are like the bouncers at your cluster’s party, keeping resources in check so your containers don’t hog all the CPU or memory. The old cgroups v1 was great — like a flip phone in the ‘90s — but cgroups v2 is the smartphone upgrade we didn’t know we needed. More about cgroups here.

Pic Credits: Google

The Prep Party: What You’ll Need

Before we start flipping switches, let’s make sure our setup is ready:

  • GKE Version: Your cluster needs to be on 1.27 or higher.
  • Runtime: We’re rocking containerd here, not Docker. Check your node pool (`default-nodepool` in my case) to confirm.
  • Machine Types: Most modern GKE machine types support cgroups v2, but double-check your nodes aren’t running on ancient relics. For `northamerica-northeast1`, we’re golden with standard types like `e2-standard-2`.
  • Permissions: You’ll need to be a cluster admin.
  • kubectl & gcloud: Install gcloud and kubectl to interact with GKE cluster

Run this to get version and other cluster config:

gcloud container clusters describe <cluster> --region <region> --project <project>

The Migration Dance: Step-by-Step

If you are using GKE, you already know there are 2 kinds of clusters — Autopilot and Standard. If you are using Autopilot, it’s going to be very easy for you. Let’s take a look at both.

Autopilot GKE clusters

Check what cgroup mode the cluster is running on. Command below:

gcloud container clusters describe <CLUSTER_NAME> --format='value(nodePools[0].config.effectiveCgroupMode)'

Replace CLUSTER_NAME with the name of your cluster. If the output is EFFECTIVE_CGROUP_MODE_V2, the cluster is running on cgroupv2. If the output is EFFECTIVE_CGROUP_MODE_V1, the cluster is running on cgroupv1. If your output shows EFFECTIVE_CGROUP_MODE_V1, read on…

Migrate nodes to cgroupv2

If your output showed EFFECTIVE_CGROUP_MODE_V1 in the step above, run this command to upgrade the nodes to v2.

gcloud container clusters update CLUSTER_NAME --autoprovisioning-cgroup-mode=v2

That’s it!! You can the command in step 1 to check the cgroups version. Happy upgrading!!

Nope, I didn’t forget about Standard clusters. Infact, I’m upgrading a standard cluster with 3 node pools, default-nodepool is one of them. For Standard clusters, we will have to change the configuration at nodepool level, unlike Autopilot clusters.

  1. Create a file with the cgroup config, I’m naming it as gke_config
linuxConfig:
cgroupMode: 'CGROUP_MODE_V2'

2. Apply the configuration by running

gcloud container node-pools update <nodepool> --cluster=<cluster> --location=<region> --system-config-from-file=<config_file>

In my case, it was:

gcloud container node-pools update default-nodepool \
--cluster=gke-test-cluster-dev \
--location=northamerica-northeast1 \
--system-config-from-file="./gke_config"

You can see the update progress in both cli and on cloud console on nodepool page. While the nodes are updating, I’ve seen my pods going down, so plan accordingly for your environment.

3. If you use node auto-provisioning for the cluster, run the following command to ensure that existing and future node pools created with node auto-provisioning use cgroupv2:

gcloud container clusters update CLUSTER_NAME --autoprovisioning-cgroup-mode=v2

That’s it! It’s all done!!

Wrapping Up: The Victory Lap

Migrating gke-test-cluster-dev to cgroups v2 wasn’t so bad, right? Go ahead, brag to your team — you’ve earned it. And if anyone asks, just say, “cgroups v2? Oh yeah, I’m basically a wizard now.” Happy clustering!

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Nikhil Naidu
Nikhil Naidu

Written by Nikhil Naidu

0 Followers

A DevOps Engineer who loves to solve problems. Experienced with all stages of DevOps Lifecycle

No responses yet

Write a response