定时作业
apiVersion: batch/v1
import "k8s.io/api/batch/v1"
定时作业
CronJob 代表单个 cron job 的配置。
apiVersion: batch/v1
kind: CronJob
metadata (ObjectMeta)
标准对象的元数据。更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
spec (CronJobSpec)
Cron job 所期望行为的规范,包括调度。更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
status (CronJobStatus)
Cron job 的当前状态。更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
CronJobSpec
CronJobSpec 描述了作业执行的样子以及何时实际运行。
jobTemplate (JobTemplateSpec),必填
指定执行 CronJob 时将创建的作业。
JobTemplateSpec 描述了从模板创建时作业应具有的数据
jobTemplate.metadata (ObjectMeta)
从此模板创建的作业的标准对象元数据。更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
jobTemplate.spec (JobSpec)
作业期望行为的规范。更多信息: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)
指定如何处理作业的并发执行。有效值为:
- "Allow"(默认):允许 CronJob 并发运行;- "Forbid":禁止并发运行,如果上一次运行尚未完成,则跳过下一次运行;- "Replace":取消当前正在运行的作业并将其替换为新作业
startingDeadlineSeconds (int64)
如果作业因任何原因错过了预定时间,则为启动作业的可选截止时间(秒)。错过的作业执行将被视为失败。
suspend (boolean)
此标志告知控制器暂停后续执行,它不适用于已启动的执行。默认为 false。
successfulJobsHistoryLimit (int32)
要保留的成功完成作业的数量。值必须是非负整数。默认为 3。
failedJobsHistoryLimit (int32)
要保留的失败完成作业的数量。值必须是非负整数。默认为 1。
CronJobStatus
CronJobStatus 表示 cron job 的当前状态。
active ([]ObjectReference)
原子性:在合并期间将被替换
当前正在运行的作业的指针列表。
lastScheduleTime (Time)
上次成功调度作业的时间信息。
Time 是 time.Time 的一个包装器,支持正确地编组到 YAML 和 JSON。提供了 time 包提供的许多工厂方法的包装器。
lastSuccessfulTime (Time)
上次成功完成作业的时间信息。
Time 是 time.Time 的一个包装器,支持正确地编组到 YAML 和 JSON。提供了 time 包提供的许多工厂方法的包装器。
CronJobList
CronJobList 是 cron job 的集合。
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): OK
401: 未授权
get
读取指定 CronJob 的状态
HTTP 请求
GET /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}/status
参数
响应
200 (CronJob): OK
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): OK
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): OK
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): OK
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): OK
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): OK
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): OK
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): OK
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): OK
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): OK
401: 未授权
本页面是自动生成的。
如果你打算报告此页面存在的问题,请在问题描述中提及此页面是自动生成的。修复可能需要在 Kubernetes 项目的其他地方进行。