是否可以在 aks 集群中启用 TTL 控制器以进行作业自动删除

Is it possible to enable TTL controller in aks cluster for job automatic deletion

我想在一定时间间隔后使用 TTL 控制器删除 aks 集群中已完成的作业,但我无法在 aks 集群中启用 TTL 控制器,这个问题有什么解决方案吗...提前致谢。 ..

AKS 中的 TTL 从 1.21.2 版本的 Kubernetes 开始可用。更多信息请查看 this github topic:

Short update on that. It is available in 1.21.2. Got the confirmation from Azure Support. So, we are currently using it.

确保您使用的是此版本或更新版本。对于旧版本,您将无法 运行 此机制。您还可以对旧版本的集群使用 kube-cleanup operator

Here 您可以找到有关如何在 AKS 群集上启用 TTL 的信息:

Another way to clean up finished Jobs (either Complete or Failed) automatically is to use a TTL mechanism provided by a TTL controller for finished resources, by specifying the .spec.ttlSecondsAfterFinished field of the Job.

Reference

When the TTL controller cleans up the Job, it will delete the Job cascadingly, i.e. delete its dependent objects, such as Pods, together with the Job. Note that when the Job is deleted, its lifecycle guarantees, such as finalizers, will be honored.

所以这可以帮助您在集群上启用 TTL 机制。