
·10 min read
The Physics of Kubernetes: What Happens When You Force a Live Cluster Into Isolation
We cut our main RKE2 dev node off the internet for 24 hours to simulate an air gap. Nothing broke while it was offline. Everything broke when we plugged it back in.
The Setup: A Simple Request
It's a classic Tuesday. My Dev Manager walks in with what sounds like a straightforward request:
"We need to simulate an air-gapped environment for 24 hours to see how the app handles zero-internet connectivity. Can you just block outbound traffic on the firewall for our RKE2 node?"
We have a dedicated air-gapped cluster that was built for this exact purpose: air-gap by design. But this time they wanted to test our main development node, a single-node RKE2 cluster on a DGX that normally lives, breathes, and updates via the internet.
Blocking egress on a dev node is one reversible firewall rule, so it sounded low-risk. It wasn't, just not in the way you'd guess. The disconnect was boring. The reconnect is what took the node down, and then I made it worse in two specific ways that are worth more than the original problem.
If you've ever thought about yanking the network cable to test DR, simulating an air gap on a cluster that wasn't built for it, or asking "what if the WAN goes down for a day", this is the post I wish I'd read first.
The Experiment: 24 Hours in the Dark
I blocked outbound traffic from the DGX to the WAN at the firewall. The cluster could still talk to itself, it just couldn't reach the internet. For 24 hours everything looked normal: pods healthy, the application serving requests.
Then I restored the connection, and within minutes the node was in trouble.
The Symptoms
gRPC message over the limit:
rpc error: code = ResourceExhausted desc = grpc: received message
larger than max (16782685 vs. 16777216)Control plane not answering:
Failed to list *v1.Pod: Get "https://127.0.0.1:6443/api/v1/pods":
context deadline exceededThen, after my config change (more on that below), the kubelet refusing to start:
start cpu manager error: could not restore state from checkpoint:
configured policy "none" differs from state checkpoint policy "static",
please drain this node and delete the CPU manager checkpoint file
"/var/lib/kubelet/cpu_manager_state" before restarting KubeletAnd after a reboot, the GPUs gone: our A100 MIG instances disappeared from the node's capacity, nvidia.com/gpu: 0.
Four symptoms, but only the first two came from the experiment. The last two I caused while fixing the first. Separating those is most of the lesson.
The Root Cause: One Real Problem, Two Self-Inflicted
The one piece of the "physics" framing I still find useful: Kubernetes has inertia and memory. Reconciliation loops keep running while you're not looking, and components write state to disk that they insist on staying consistent with later. Pulling the network doesn't pause any of that.
1. The real problem: a CRI response that grew past 16 MB
The easy story is "a day of queued traffic flooded the cluster on reconnect". That's not what the error says, and on a single node it can't be. The kubelet talks to the API server over 127.0.0.1, and to containerd over a local socket. Blocking the WAN doesn't queue anything between them.
Read the numbers instead. 16777216 is exactly 16 MiB, the default gRPC message limit. 16782685 is the message that arrived. It was over by 5,469 bytes. That's not a flood, that's a response that slowly grew until it crossed a line.
The classic source of this error is the kubelet asking containerd for a list (ListContainers / ListPodSandbox) and getting back too many objects. Each object is small, but there were enough of them. A day offline grows that list: everything that needs the outside world (image pulls, workloads calling external endpoints) fails and retries for 24 hours, and the node accumulates container and sandbox records much faster than on a normal day. On reconnect, everything retries at once, the node gets busy, and one more list pushed the response over the limit.
When the kubelet can't list its own containers, it can't tell what's running. On RKE2 that's serious, because the control plane (etcd, the API server) runs as static pods under that same kubelet. Hence the second symptom: the API server on localhost timing out.
How to check if this is your problem too:
export CRI_CONFIG_FILE=/var/lib/rancher/rke2/agent/etc/crictl.yaml
crictl ps -a | wc -l # all containers, including exited
crictl ps -a --state exited | wc -l # the dead weight
crictl pods | wc -l # sandboxesIf those numbers are in the thousands on a single node, you've found the list.
2. Self-inflicted: the YAML trap
While the node was struggling, I edited /etc/rancher/rke2/config.yaml to add kubelet event rate limits. The file already had a kubelet-arg block further up, and I added a second one:
# Block 1 - Our original settings
kubelet-arg:
- "max-pods=200"
- "cpu-manager-policy=static"
- "reserved-cpus=0-7"
# ... 50 lines later ...
# Block 2 - Added during troubleshooting
kubelet-arg:
- "event-qps=10"
- "event-burst=50"Duplicate keys in YAML don't merge. The parser keeps the last one, so the second block silently replaced the first:
kubelet-arg:
- "event-qps=10"
- "event-burst=50"
# max-pods, cpu-manager-policy, reserved-cpus: GONEThe kubelet came up with defaults: max-pods 110, cpu-manager-policy none, no reserved CPUs. No warning anywhere.
The mistake isn't that I don't know how YAML works. It's that I changed config on a node that was already failing, in a long file, without linting or diffing. Changing a second variable mid-incident is how one problem becomes two.
3. Self-inflicted: the CPU manager remembers
With the static policy, the kubelet keeps a checkpoint at /var/lib/kubelet/cpu_manager_state: the policy it ran with and which containers own which cores.
{
"policyName": "static",
"defaultCpuSet": "8-95",
"entries": {
"pod-uid-1": {
"container-1": "16-23"
}
},
"checksum": 123456789
}On startup it compares that checkpoint with its configured policy. The checkpoint said static, the broken config now said none, so the kubelet refused to start (the error at the top). That's deliberate. If it silently switched policies, containers that were promised exclusive cores would suddenly share them. Refusing is the safe choice.
And again, on RKE2 a kubelet that won't start means a control plane that won't start:
config change → kubelet refuses to start → static pods down → no API serverBonus: what a reboot resets
At that point I rebooted the node to get a clean start. A reasonable move on its own, but a reboot resets more than processes. MIG splits one A100 into up to 7 isolated GPU instances. The MIG mode survives a reboot. The GPU instances you carve inside it do not. On this node they had been created by hand with nvidia-smi, so nothing recreated them on boot, and the node reported nvidia.com/gpu: 0.
The Recovery
The order I'd do it in again. Fix config first, then state, then the original problem.
Step 1: Fix the config
One kubelet-arg block, everything in it:
kubelet-arg:
- "max-pods=200"
- "cpu-manager-policy=static"
- "reserved-cpus=0-7"
- "cpu-manager-reconcile-period=10s"
- "event-qps=10"
- "event-burst=50"Lint before you restart anything. yamllint flags duplicate keys out of the box:
yamllint /etc/rancher/rke2/config.yaml
# 12:1 error duplication of key "kubelet-arg" in mapping (key-duplicates)Better still, stop editing the main file. RKE2 also reads drop-in files from /etc/rancher/rke2/config.yaml.d/, and a key ending in + appends instead of replacing:
# /etc/rancher/rke2/config.yaml.d/50-events.yaml
kubelet-arg+:
- "event-qps=10"
- "event-burst=50"That's the format that makes this mistake impossible, and it gives every change its own file you can review and delete.
Step 2: Clear the CPU manager state
The kubelet's own error tells you what to do: drain, delete the checkpoint, restart. On a single-node cluster there's nowhere to drain to, so you accept the pod restarts:
systemctl stop rke2-server
rm -f /var/lib/kubelet/cpu_manager_state
systemctl start rke2-serverEven with the config back to static, delete it. The old checkpoint still references container IDs and CPU sets from the previous run.
On RKE2 the kubelet doesn't log to the rke2-server journal, it has its own file:
tail -f /var/lib/rancher/rke2/agent/logs/kubelet.log | grep -i cpu_managerYou're done when the checkpoint error stops and the control-plane static pods come back.
Step 3: Shrink the list, then decide about limits
The real fix for an oversized CRI response is a smaller response. Remove the exited containers and dead sandboxes:
crictl ps -a --state exited -q | xargs -r crictl rm
crictl pods --state NotReady -q | xargs -r crictl rmpI also raised containerd's gRPC limits, in /var/lib/rancher/rke2/agent/etc/containerd/config.toml.tmpl:
version = 2
[grpc]
max_recv_message_size = 67108864 # 64MB (4x default)
max_send_message_size = 67108864 # 64MB
[plugins."io.containerd.grpc.v1.cri"]
# ... rest of config ...Why .tmpl and not .toml? RKE2 regenerates config.toml on every restart, so a direct edit is gone on the next one.
systemctl restart rke2-server
grep max_recv_message_size /var/lib/rancher/rke2/agent/etc/containerd/config.tomlBe honest with yourself about what this does, though. It raises the limit on messages containerd receives. When the oversized message is a list response the kubelet receives, the kubelet's own client limit is what you're hitting. Cleaning up the list is the fix, and the containerd change is just headroom.
Step 4: Restore MIG, then make it survive reboots
Immediate fix, on an A100 80GB:
# MIG mode persists across reboots once set; make sure it's on
sudo nvidia-smi -i 0 -mig 1
# 7 x 1g.10gb instances (profile ID 19 on A100 80GB) + compute instances
sudo nvidia-smi mig -i 0 -cgi 19,19,19,19,19,19,19 -C
# Verify
nvidia-smi mig -lgiProfile IDs differ per GPU model, so check nvidia-smi mig -lgip before you copy this.
Quick and dirty: a systemd unit
/etc/systemd/system/nvidia-mig-setup.service:
[Unit]
Description=NVIDIA MIG Configuration
After=nvidia-persistenced.service
[Service]
Type=oneshot
ExecStart=/usr/bin/nvidia-smi mig -i 0 -cgi 19,19,19,19,19,19,19 -C
RemainAfterExit=yes
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable --now nvidia-mig-setup.serviceWhat I'd actually use: the GPU Operator's MIG manager
If the GPU Operator is already on the node, let its mig-manager own the layout. Don't run the systemd unit next to it, they'll fight. Enable the manager in the ClusterPolicy:
apiVersion: nvidia.com/v1
kind: ClusterPolicy
metadata:
name: cluster-policy
spec:
mig:
strategy: mixed
migManager:
enabled: trueThen pick a layout with a node label. mig-manager applies it, and re-applies it after a reboot:
kubectl label node <node> nvidia.com/mig.config=all-1g.10gb --overwriteThe Timeline
T+0h : Firewall blocks outbound traffic (DGX -> WAN)
T+24h : Firewall restored
T+24h:05 : CRI list response exceeds the 16MB gRPC limit
T+24h:10 : API server on localhost stops answering
T+24h:15 : Config change during the incident, YAML collision introduced
T+24h:20 : Kubelet refuses to start: cpu_manager_state mismatch
T+24h:25 : Static pods (control plane) can't start
T+24h:30 : Node reboot for a clean start
T+24h:35 : MIG instances gone after the reboot
T+25h : Coffee break. No more changes until there's a plan.
T+26h : Systematic recovery (steps above)
T+28h : Cluster fully restoredThe interesting part is T+24h:15 to T+24h:35. One real problem turned into three in twenty minutes, all from moving fast. The best decision of the day was the coffee break at T+25h: stop touching things, and only then fix it, in order.
What I Took Away From It
Air-gap by force is not air-gap by design. Our real air-gapped cluster has a local registry (Harbor), pre-cached images and charts, internal NTP, and nothing in it expects the internet. A live dev node has none of that. If the question is "how does the app behave offline", test it on the cluster built for offline.
Plan for the reconnect, not just the disconnect. Offline, failures are slow and quiet. The reconnect is when everything retries at once.
Read the numbers in the error. "16782685 vs 16777216" says a response just crossed a limit, not a flood. Do that arithmetic before you build theories.
Kubernetes writes things down, and holds you to them. cpu_manager_state, memory_manager_state, /var/lib/kubelet/device-plugins/. These outlive restarts and config changes, and the kubelet would rather not start than silently disagree with them. When you change kubelet policies, the state files are part of the change.
One change at a time during an incident, and lint it. YAML duplicate keys fail silently. In RKE2, use config.yaml.d drop-ins with + keys so a new setting can't erase old ones.
Know what a reboot resets before you reboot. MIG instances, clocks, power limits: if they were set by hand, a reboot wipes them. Either the GPU Operator owns them or a boot-time unit does.
If I Ran This Again
Before disconnecting
# Baseline
kubectl get events --all-namespaces > events-before.txt
kubectl top nodes > resources-before.txt
crictl ps -a | wc -l > cri-count-before.txt
# Snapshot kubelet state and the RKE2 config
cp -r /var/lib/kubelet /backup/kubelet-state-$(date +%s)
cp -r /etc/rancher/rke2 /backup/rke2-config-$(date +%s)
# Record the GPU layout
nvidia-smi mig -lgi > mig-config-backup.txtDuring the disconnect
Watch what's growing:
crictl ps -a | wc -l
journalctl --disk-usage
du -sh /var/lib/rancher/rke2/server/db/etcdIf the container count keeps climbing, clean exited containers before you reconnect, not after.
When reconnecting
Stay at the keyboard and watch it, don't just flip the firewall rule and walk away:
tail -f /var/lib/rancher/rke2/agent/logs/kubelet.log
kubectl get --raw /metrics | grep apiserver_request_durationFor production
Don't do this experiment on production. Build a dedicated air-gapped cluster from day one.
Have you hit something like this after a long disconnect? I'd be curious to hear how you got out of it.
A note on how this was written: I used AI to help with phrasing and structure. The tone, the opinions, the war stories, the code, and everything else here are mine.