返回综合榜
开发工具与框架Kubernetes Blog

Kubernetes v1.37:追踪 PersistentVolumeClaim 的最后使用时间(Beta)

Kubernetes v1.37 将 PersistentVolumeClaimUnusedSinceTime 特性门控提升至 Beta 并默认启用。PVC 保护控制器现在会为每个 PersistentVolumeClaim 添加一个 Unused 条件,原生告知管理员是否仍有运行中的 Pod 引用该卷。

当没有任何非终止态的 Pod 引用 PVC 时,条件为 Unused=True,原因为 NoPodsUsingPVC;当至少有一个运行中或待调度的 Pod 引用时,条件为 Unused=False,原因为 PodUsingPVC。已终止的 Pod(Succeeded 或 Failed)不计入使用,因此采用 restartPolicy: Never 且已完成的批处理任务不会让 PVC 保持在使用状态,而即使是无法调度的待调度 Pod 也会计入。由于该条件携带标准的 lastTransitionTime 字段,它还精确记录了 PVC 变为空闲的时间,可通过 kubectl 与 jq 查询找出闲置超过指定时长的卷。

该特性解决了大规模集群中常见的成本问题:Kubernetes 在 Pod 被删除时不会删除 PVC,孤立卷会不断累积并悄悄占用存储。此前判断 PVC 是否仍在使用需要交叉比对 Pod、PersistentVolume 和 PVC,通常要借助自定义脚本。该特性在 v1.36 中以 Alpha 引入,需显式开启;Beta 版本具备完整的端到端测试覆盖。项目计划根据反馈在后续版本将其晋升为 GA,对应 KEP-5541。

Kubernetes v1.37: Tracking When a PersistentVolumeClaim Was Last Used (Beta)

Kubernetes v1.37 promotes the PersistentVolumeClaimUnusedSinceTime feature gate to Beta and enables it by default. The PVC protection controller now adds an Unused condition to every PersistentVolumeClaim, telling administrators natively whether any running pod still references the volume.

The condition is set to Unused=True with reason NoPodsUsingPVC when no non-terminal pods reference the PVC, and Unused=False with reason PodUsingPVC when at least one running or pending pod does. Terminated pods (Succeeded or Failed) do not count as usage, so completed batch jobs with restartPolicy: Never will not keep a PVC marked in use, while even unschedulable pending pods do count. Because the condition carries the standard lastTransitionTime field, it also records exactly when a PVC became idle, which makes it possible to find volumes unused for more than a given period with a kubectl and jq query.

The feature addresses a common cost problem in large clusters: Kubernetes does not delete PVCs when their pods are removed, so orphaned volumes accumulate and silently consume storage. Previously, identifying whether a PVC was still in use required cross-referencing pods, PersistentVolumes, and PVCs, often via custom scripts. The feature was introduced as Alpha in v1.36 requiring explicit opt-in; in Beta it has full end-to-end test coverage. The project intends to graduate it to GA in a future release pending feedback, tracked under KEP-5541.

KubernetesPersistentVolumeClaimstorageBetacloud cost
综合10
质量92
猎物热度0
时效0
信息来源1 个来源,主来源:Kubernetes Blog

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

查看来源