定時作業
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.club.tw/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 專案的其他地方進行。