返回综合榜
云计算与基础设施Kubernetes Blog

Kubernetes 向 cgroup v2 的迁移:你需要知道的事

Kubernetes 已弃用 cgroup v1,从 v1.35 开始 kubelet 的 failCgroupV1 默认为 true,因此在 cgroup v1 节点上 kubelet 默认无法启动。管理员可以在 kubelet 配置中临时设置 failCgroupV1: false,但该回退选项计划在 Kubernetes v1.38 中移除,相关工作由 KEP-5573 跟踪。对于 kubeadm 管理的集群,当检测到 cgroup v1 且 kubelet 为 v1.35 或更高版本时,SystemValidation 预检会在 kubeadm init、join 和 upgrade 时返回错误。

cgroup v2 解锁了 v1 无法提供的功能。Memory QoS 在 v1.36 中仍为 alpha,但现在将节流(memory.high)与预留分离,并通过 memoryReservationPolicy: TieredReservation 提供分级保护,将 Guaranteed Pod 的请求映射到 memory.min,将 Burstable Pod 的请求映射到 memory.low。在 cgroup v2 节点上,kubelet 默认将 singleProcessOOMKill 设为 false,因此 memory.oom.group 会在 OOM 时一并杀掉容器内的所有进程。cgroup v2 还正式支持 rootless 容器所依赖的委派机制,PSI 指标也依赖它。

迁移中有若干细节值得注意。较新的 OCI 运行时(crun v1.23、runc v1.3.2)采用改进的非线性方式将 cpu.shares 转换为 cpu.weight,因此预测精确 cpu.weight 值的监控或策略工具可能需要更新。v1.36 中 Pod 级资源的原地更新要实现准确的聚合管控需要 cgroup v2。kubelet 通过 RuntimeConfig CRI RPC 自动检测 cgroup 驱动(自 v1.34 起稳定),需要 containerd v2.0+ 或 CRI-O v1.28+。Kubernetes 将内核 5.8 记录为最低版本(使用 Memory QoS 建议 5.9+)。

仍在使用 v1.35 之前版本的集群应在升级前将所有 Linux 节点迁移到 cgroup v2,或规划临时覆盖配置。一个已知注意事项:kubelet 仍不将 active_file 内存视为可用内存,因此 I/O 密集型工作负载在迁移后仍可能因内存压力被驱逐。

The Shift to cgroup v2 in Kubernetes: What You Need to Know

Kubernetes has deprecated cgroup v1, and starting with v1.35 the kubelet's failCgroupV1 defaults to true, so the kubelet no longer starts on cgroup v1 nodes by default. Administrators can temporarily set failCgroupV1: false in the kubelet configuration, but removal is scheduled for Kubernetes v1.38 and tracked in KEP-5573. For kubeadm clusters, the SystemVerification preflight check returns an error during kubeadm init, join, and upgrade when it detects cgroup v1 with kubelet v1.35 or later.

cgroup v2 unlocks features that v1 cannot provide. Memory QoS, still alpha in v1.36, now separates throttling (memory.high) from reservation and adds tiered protection via memoryReservationPolicy: TieredReservation, mapping Guaranteed Pod requests to memory.min and Burstable requests to memory.low. On cgroup v2 nodes the kubelet defaults singleProcessOOMKill to false, so memory.oom.group kills all processes in a container together on OOM. cgroup v2 also officially supports delegation, which rootless containers rely on, and PSI metrics require it.

Several migration details deserve attention. Newer OCI runtimes (crun v1.23, runc v1.3.2) use an improved non-linear conversion from cpu.shares to cpu.weight, so monitoring or policy tools predicting exact cpu.weight values may need updates. Accurate aggregate enforcement for in-place Pod-level resource updates in v1.36 requires cgroup v2. The kubelet's automatic cgroup driver detection via the RuntimeConfig CRI RPC, stable since v1.34, needs containerd v2.0+ or CRI-O v1.28+. Kubernetes documents kernel 5.8 as the minimum (5.9+ recommended for Memory QoS).

Clusters on releases older than v1.35 should migrate every Linux node to cgroup v2 before upgrading or plan the temporary override. A known caveat: the kubelet still does not treat active_file memory as available, so I/O-intensive workloads may see memory pressure evictions even after migration.

kubernetescgroup v2kubeletlinuxmemory qosdeprecationcontainers
综合8
质量89
猎物热度0
时效0
信息来源1 个来源,主来源:Kubernetes Blog

猎鹰不保存原文正文。标题与摘要用于快速发现信息,事实细节请以来源原文为准。

查看来源