gpt4 book ai didi

kubernetes - 超时的 Cron 作业

转载 作者:行者123 更新时间:2023-12-02 11:28:32 24 4
gpt4 key购买 nike

有没有办法为 kubernetes CronJob 提供超时?

我需要安排一个根据 Cron 计划运行的任务,但我需要将此任务的执行时间限制为仅 20 秒。如果任务运行时间超过 20 秒,则应终止。
我尝试使用 .spec.startingDeadlineSeconds但这没有帮助。

最佳答案

使用 cronjob.spec.jobTemplate.spec.activeDeadlineSeconds :

FIELDS:

activeDeadlineSeconds Specifies the duration in seconds relative to the startTime that the job may be active before the system tries to terminate it; value must be positive integer



From documentation:

Another way to terminate a Job is by setting an active deadline. Do this by setting the .spec.activeDeadlineSeconds field of the Job to a number of seconds.

The activeDeadlineSeconds applies to the duration of the job, no matter how many Pods are created. Once a Job reaches activeDeadlineSeconds, all of its Pods are terminated and the Job status will become type: Failed with reason: DeadlineExceeded.

关于kubernetes - 超时的 Cron 作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55431218/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com