CronJob
apiVersion: batch/v1
import "k8s.io/api/batch/v1"
CronJob
CronJob 表示单个定时任务的配置。
apiVersion: batch/v1
kind: CronJob
metadata (ObjectMeta)
标准对象的元数据。更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
spec (CronJobSpec)
定时任务期望行为的规约,包括其执行计划。更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
status (CronJobStatus)
定时任务的当前状态。更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
CronJobSpec
CronJobSpec 描述了 Job 执行的外观以及何时实际运行。
jobTemplate (JobTemplateSpec),必需
指定执行 CronJob 时将创建的 Job。
JobTemplateSpec 描述了 Job 从模板创建时应包含的数据
jobTemplate.metadata (ObjectMeta)
从此模板创建的 Job 的标准对象元数据。更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
jobTemplate.spec (JobSpec)
Job 期望行为的规约。更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
schedule (string),必需
Cron 格式的执行计划,参阅 https://en.wikipedia.org/wiki/Cron。
timeZone (string)
给定执行计划的时区名称,参阅 https://en.wikipedia.org/wiki/List_of_tz_database_time_zones。如果未指定,则默认为 kube-controller-manager 进程的时区。有效的时区名称及其时区偏移量由 API 服务器在 CronJob 验证期间和控制器管理器在执行期间从系统范围的时区数据库加载。如果找不到系统范围的时区数据库,则使用捆绑版本的数据库。如果在 CronJob 的生命周期内或由于主机配置更改导致时区名称失效,控制器将停止创建新的 Job,并会创建一个原因码为 UnknownTimeZone 的系统事件。更多信息可在 https://kubernetes.ac.cn/docs/concepts/workloads/controllers/cron-jobs/#time-zones 中找到。
concurrencyPolicy (string)
指定如何处理 Job 的并发执行。有效值为
- "Allow" (默认):允许 CronJob 并发运行;- "Forbid":禁止并发运行,如果之前的运行尚未完成,则跳过下一次运行;- "Replace":取消当前正在运行的 Job 并将其替换为新的 Job
startingDeadlineSeconds (int64)
如果 Job 因故错过了计划时间,则指定启动 Job 的可选截止时间(秒)。错过的 Job 执行将被计为失败。
suspend (boolean)
此标志指示控制器暂停后续执行,但不适用于已启动的执行。默认为 false。
successfulJobsHistoryLimit (int32)
要保留的成功完成的 Job 数量。值必须为非负整数。默认为 3。
failedJobsHistoryLimit (int32)
要保留的失败完成的 Job 数量。值必须为非负整数。默认为 1。
CronJobStatus
CronJobStatus 表示定时任务的当前状态。
active ([]ObjectReference)
原子操作:合并期间将被替换
当前正在运行的 Job 列表的指针。
lastScheduleTime (Time)
Job 上一次成功调度的信息。
Time 是 time.Time 的封装,支持正确地序列化为 YAML 和 JSON。提供了 time 包中许多工厂方法的封装。
lastSuccessfulTime (Time)
Job 上一次成功完成的信息。
Time 是 time.Time 的封装,支持正确地序列化为 YAML 和 JSON。提供了 time 包中许多工厂方法的封装。
CronJobList
CronJobList 是定时任务的集合。
apiVersion: batch/v1
kind: CronJobList
metadata (ListMeta)
标准列表元数据。更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
items ([]CronJob),必需
items 是 CronJob 的列表。
操作
get
读取指定的 CronJob
HTTP 请求
GET /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}
参数
响应
200 (CronJob): 成功
401: 未授权
get
读取指定的 CronJob 状态
HTTP 请求
GET /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}/status
参数
响应
200 (CronJob): 成功
401: 未授权
list
列出或监听 CronJob 类型的对象
HTTP 请求
GET /apis/batch/v1/namespaces/{namespace}/cronjobs
参数
namespace (在路径中): string,必需
allowWatchBookmarks (在查询中): boolean
continue (在查询中): string
fieldSelector (在查询中): string
labelSelector (在查询中): string
limit (在查询中): integer
pretty (在查询中): string
resourceVersion (在查询中): string
resourceVersionMatch (在查询中): string
sendInitialEvents (在查询中): boolean
timeoutSeconds (在查询中): integer
watch (在查询中): boolean
响应
200 (CronJobList): 成功
401: 未授权
list
列出或监听 CronJob 类型的对象
HTTP 请求
GET /apis/batch/v1/cronjobs
参数
allowWatchBookmarks (在查询中): boolean
continue (在查询中): string
fieldSelector (在查询中): string
labelSelector (在查询中): string
limit (在查询中): integer
pretty (在查询中): string
resourceVersion (在查询中): string
resourceVersionMatch (在查询中): string
sendInitialEvents (在查询中): boolean
timeoutSeconds (在查询中): integer
watch (在查询中): boolean
响应
200 (CronJobList): 成功
401: 未授权
create
创建一个 CronJob
HTTP 请求
POST /apis/batch/v1/namespaces/{namespace}/cronjobs
参数
namespace (在路径中): string,必需
body: CronJob,必需
dryRun (在查询中): string
fieldManager (在查询中): string
fieldValidation (在查询中): string
pretty (在查询中): string
响应
200 (CronJob): 成功
201 (CronJob): 已创建
202 (CronJob): 已接受
401: 未授权
update
替换指定的 CronJob
HTTP 请求
PUT /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}
参数
name (在路径中): string,必需
CronJob 的名称
namespace (在路径中): string,必需
body: CronJob,必需
dryRun (在查询中): string
fieldManager (在查询中): string
fieldValidation (在查询中): string
pretty (在查询中): string
响应
200 (CronJob): 成功
201 (CronJob): 已创建
401: 未授权
update
替换指定的 CronJob 状态
HTTP 请求
PUT /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}/status
参数
name (在路径中): string,必需
CronJob 的名称
namespace (在路径中): string,必需
body: CronJob,必需
dryRun (在查询中): string
fieldManager (在查询中): string
fieldValidation (在查询中): string
pretty (在查询中): string
响应
200 (CronJob): 成功
201 (CronJob): 已创建
401: 未授权
patch
部分更新指定的 CronJob
HTTP 请求
PATCH /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}
参数
name (在路径中): string,必需
CronJob 的名称
namespace (在路径中): string,必需
body: Patch,必需
dryRun (在查询中): string
fieldManager (在查询中): string
fieldValidation (在查询中): string
force (在查询中): boolean
pretty (在查询中): string
响应
200 (CronJob): 成功
201 (CronJob): 已创建
401: 未授权
patch
部分更新指定的 CronJob 状态
HTTP 请求
PATCH /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}/status
参数
name (在路径中): string,必需
CronJob 的名称
namespace (在路径中): string,必需
body: Patch,必需
dryRun (在查询中): string
fieldManager (在查询中): string
fieldValidation (在查询中): string
force (在查询中): boolean
pretty (在查询中): string
响应
200 (CronJob): 成功
201 (CronJob): 已创建
401: 未授权
delete
删除一个 CronJob
HTTP 请求
DELETE /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}
参数
name (在路径中): string,必需
CronJob 的名称
namespace (在路径中): string,必需
body: DeleteOptions
dryRun (在查询中): string
gracePeriodSeconds (在查询中): integer
ignoreStoreReadErrorWithClusterBreakingPotential (在查询中): boolean
pretty (在查询中): string
propagationPolicy (在查询中): string
响应
200 (Status): 成功
202 (Status): 已接受
401: 未授权
deletecollection
删除 CronJob 集合
HTTP 请求
DELETE /apis/batch/v1/namespaces/{namespace}/cronjobs
参数
namespace (在路径中): string,必需
body: DeleteOptions
continue (在查询中): string
dryRun (在查询中): string
fieldSelector (在查询中): string
gracePeriodSeconds (在查询中): integer
ignoreStoreReadErrorWithClusterBreakingPotential (在查询中): boolean
labelSelector (在查询中): string
limit (在查询中): integer
pretty (在查询中): string
propagationPolicy (在查询中): string
resourceVersion (在查询中): string
resourceVersionMatch (在查询中): string
sendInitialEvents (在查询中): boolean
timeoutSeconds (在查询中): integer
响应
200 (Status): 成功
401: 未授权
本页是自动生成的。
如果您计划报告此页面问题,请在问题描述中提及本页是自动生成的。修复可能需要在 Kubernetes 项目的其他地方进行。