您正在查看 Kubernetes 版本的文档: v1.24

Kubernetes v1.24 版本的文档已不再维护。您现在看到的版本来自于一份静态的快照。如需查阅最新文档,请点击 最新版本。

CronJob

CronJob 代表单个定时作业 (Cron Job) 的配置。

apiVersion: batch/v1

import "k8s.io/api/batch/v1"

CronJob

CronJob 代表单个定时作业(Cron Job) 的配置。


CronJobSpec

CronJobSpec 描述了作业的执行方式和实际将运行的时间。


  • concurrencyPolicy (string)

    指定如何处理作业的并发执行。 有效值为:

    • "Allow" (默认):允许 CronJobs 并发运行;
    • "Forbid":禁止并发运行,如果上一次运行尚未完成则跳过下一次运行;
    • "Replace":取消当前正在运行的作业并将其替换为新作业
  • startingDeadlineSeconds (int64)

    可选字段。当作业因为某种原因错过预定时间时,设定作业的启动截止时间(秒)。错过排期的作业将被视为失败的作业。

  • suspend (boolean)

    这个标志告诉控制器暂停后续的执行,它不适用于已经开始的执行。默认为 false。

  • successfulJobsHistoryLimit (int32)

    要保留的成功完成作业数。值必须是非负整数。默认值为 3。

  • failedJobsHistoryLimit (int32)

    要保留的以失败状态结束的作业个数。值必须是非负整数。默认值为 1。

CronJobStatus

CronJobStatus 表示某个定时作业的当前状态。


  • active ([]ObjectReference)

    Atomic: 将在合并过程中被替换

    指向当前正在运行的作业的指针列表。

  • lastScheduleTime (Time)

    上次成功调度作业的时间信息。

    Time 是对 time.Time 的封装,它支持对 YAML 和 JSON 的正确编排。为 time 包提供的许多工厂方法模式提供了包装器。

  • lastSuccessfulTime (Time)

    上次成功完成作业的时间信息。

    Time 是对 time.Time 的封装,它支持对 YAML 和 JSON 的正确编排。为 time 包提供的许多工厂方法模式提供了包装器。

CronJobList

CronJobList 是定时作业的集合。


  • apiVersion: batch/v1

  • kind: CronJobList

  • items ([]CronJob), required

    items 是 CronJobs 的列表。

操作


get 查看指定的 CronJob

HTTP 请求

GET /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}

参数

  • name (路径参数): string, 必需

    CronJob 的名称

  • namespace (路径参数): string, 必需

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (CronJob): OK

401: Unauthorized

get 查看指定 CronJob 的状态

HTTP 请求

GET /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}/status

参数

  • name (路径参数): string, 必需

    CronJob 的名称

  • namespace (路径参数): string, 必需

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (CronJob): OK

401: Unauthorized

list 查看或监视 CronJob 类别的对象

HTTP 请求

GET /apis/batch/v1/namespaces/{namespace}/cronjobs

参数

  • namespace (路径参数): string, 必需

    namespace

  • continue (查询参数): string

    continue

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

  • watch (查询参数): boolean

    watch

响应

200 (CronJobList): OK

401: Unauthorized

list 查看或监视 CronJob 类型的对象

HTTP 请求

GET /apis/batch/v1/cronjobs

参数

  • limit (in query): integer

    limit

  • pretty (in query): string

    pretty

  • watch (in query): boolean

    watch

响应

200 (CronJobList): OK

401: Unauthorized

create 创建一个 CronJob

HTTP 请求

POST /apis/batch/v1/namespaces/{namespace}/cronjobs

参数

  • namespace (路径参数): string, 必需

    namespace

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (CronJob): OK

201 (CronJob): Created

202 (CronJob): Accepted

401: Unauthorized

update 替换指定的 CronJob

HTTP 请求

PUT /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}

参数

  • name (路径参数): string, 必需

    CronJob 的名称

  • namespace (路径参数): string, 必需

    namespace

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (CronJob): OK

201 (CronJob): Created

401: Unauthorized

update 替换指定 CronJob 的状态

HTTP 请求

PUT /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}/status

参数

  • name (路径参数): string, 必需

    CronJob 的名称

  • namespace (路径参数): string, 必需

    namespace

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (CronJob): OK

201 (CronJob): Created

401: Unauthorized

patch 部分更新指定的 CronJob

HTTP 请求

PATCH /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}

参数

  • name (路径参数): string, 必需

    CronJob 的名称

  • namespace (路径参数): string, 必需

    namespace

  • dryRun (查询参数): string

    dryRun

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (CronJob): OK

201 (CronJob): Created

401: Unauthorized

patch 部分更新指定 CronJob 的状态

HTTP 请求

PATCH /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}/status

参数

  • name (路径参数): string, 必需

    CronJob 的名称

  • namespace (路径参数): string, 必需

    namespace

  • dryRun (参数参数): string

    dryRun

  • force (参数参数): boolean

    force

  • pretty (参数参数): string

    pretty

响应

200 (CronJob): OK

201 (CronJob): Created

401: Unauthorized

delete 删除一个 CronJob

HTTP 请求

DELETE /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}

参数

  • name (路径参数): string, 必需

    CronJob 的名称

  • namespace (路径参数): string, 必需

    namespace

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除一组 CronJob

HTTP 请求

DELETE /apis/batch/v1/namespaces/{namespace}/cronjobs

参数

  • namespace (路径参数): string, 必需

    namespace

  • continue (查询参数): string

    continue

  • dryRun (查询参数): string

    dryRun

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

响应

200 (Status): OK

401: Unauthorized