Spin Infrastructure Adventures: Containers, Systemd, and CGroups
Spin development instances run systemd inside Kubernetes containers, and processes launched through systemd escaped the pod's memory cgroup, so pod memory limits were not enforced and instances could exceed their allotment and disturb neighbours. Using kubectl top and a stress test, the team showed that processes started via kubectl exec landed in the kubepods cgroup while those started via spin shell landed in an effectively unlimited hierarchy. Reproductions across containerd, Docker and Podman traced the cause to the cgroupfs driver: Podman's systemd cgroup driver correctly delegates limits to the in-container systemd. The leak came from bind-mounting /sys/fs/cgroup read-only, which leaves subdirectories writable, and the fix is switching to the systemd cgroup driver, which Container-Optimized OS plans to make the default in version 101.
Related posts
- Debugging Systems in the Cloud: MySQL, Kubernetes, and Cgroups
Shopify Engineering hardMasterSlow MySQL Pod startup and degraded query performance on long-running GKE nodes in Shopify's KateSQL platform traced back to a Linux kernel memory cgroup leak: roughly 50K zombie memory cgroups made mem_cgroup_commit_charge slow, so each 128MB mmap during InnoDB buffer pool initialization took about 100 ms. The investigation used strace, perf flamegraphs, slabtop and /proc/cgroups, and Google kernel engineers confirmed it as a side effect of slab reparenting on cgroup removal. Forcing kubepods memory.force_empty cut cgroups to about 1800, and an 80G buffer pool then initialized in five seconds. The permanent fix was upgrading to GKE 1.18 (COS 85, kernel 5.4). Interim options included recycling nodes, dropping caches and isolating short-lived Pods.
- The Shift to cgroup v2 in Kubernetes: What You Need to Know
Kubernetes Blog mediumAdeptKubernetes has deprecated cgroup v1: from v1.35 the kubelet refuses to start on cgroup v1 nodes by default (`failCgroupV1: true`), kubeadm preflight errors on it, and the fallback is slated for removal in v1.38. cgroup v2 enables Memory QoS with `memory.high` throttling and tiered `memory.min`/`memory.low` reservations, container-wide OOM kills via `memory.oom.group`, safe rootless delegation, eBPF-based device control, PSI metrics, and accurate Pod-level in-place resizing. Migration requires kernel 5.8+ (5.9+ for Memory QoS), a cgroup v2-capable runtime, and matching cgroup drivers, ideally systemd with CRI auto-detection. A step-by-step procedure traces Pod resource limits from the API through CRI, OCI spec, and systemd scope down to the actual cgroup files.
- What else runs on your Postgres server, and how do we stop it from taking the database down?
ClickHouse mediumAdept
Supporting processes on a managed Postgres VM (PgBouncer, WAL-G, Prometheus, exporters, log collector, watchdogs) share memory, CPU and disk with the database, so a leak or CPU burst in any of them can take it down. ClickHouse Managed Postgres confines them to a cgroup v2 slice using systemd MemoryHigh/MemoryMax, with per-service GOMEMLIMIT values summing below memory.high. Go's GC reacts first, the kernel throttles at memory.high, and any OOM at memory.max is scoped away from Postgres, which runs in a separate cgroup. Backups get reduced CPU weight, WAL-G buffers and log-collector memory are bounded, exported metrics are allowlisted, and a disk-full watchdog kills application sessions while exempting replication and monitoring roles.
- The case of the vanishing CPU: A Linux kernel debugging story
ClickHouse hardMaster
Intermittent, indefinite CPU saturation of ClickHouse Cloud pods, seen only on GCP, turned out to be a Linux kernel memory-management livelock. Pods sat just under their cgroup memory limit while every CPU spun in shrink_lruvec during memcg reclaim triggered by page-cache readahead on page faults. The investigation used gdb backtraces, bpftrace syscall latency histograms, perf top/stat, pidstat and an on-call runbook to reach a reproducible test case and a kernel fix, after which another kernel bug surfaced. One lesson along the way: signal-based user-space stack traces hide kernel time entirely, so gdb backtraces pointed the team at the wrong code.
- Kubernetes v1.38 Sneak Peek
Kubernetes Blog hardMasterKubernetes v1.38, planned for December 16, 2026, will require container runtimes to report the cgroup driver via the CRI RuntimeConfig RPC. The kubelet will reject the cgroupDriver config field unless the temporary LegacyCgroupDriverFallback gate is enabled, and kubeadm preflight will fail on runtimes that lack the RPC. On cgroup v2 nodes using LimitedSwap, swap limits will follow pod-level memory settings, so Pods whose pod-level request equals their limit get no swap. The kubectl WebSocket opt-out environment variables and the kuberc allowlist `name` field are removed. kuberc, pod-level resources and DRA partitionable devices are expected to go stable, and an alpha EvictionRequest API lets responders prepare Pods before eviction while still respecting PDBs.