2 Copyright 2017 The Kubernetes Authors.
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
20 batchv1 "k8s.io/api/batch/v1"
22 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
25 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
27 // JobTemplate describes a template for creating copies of a predefined pod.
28 type JobTemplate struct {
29 metav1.TypeMeta `json:",inline"`
30 // Standard object's metadata.
31 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
33 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
35 // Defines jobs that will be created from this template.
36 // https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
38 Template JobTemplateSpec `json:"template,omitempty" protobuf:"bytes,2,opt,name=template"`
41 // JobTemplateSpec describes the data a Job should have when created from a template
42 type JobTemplateSpec struct {
43 // Standard object's metadata of the jobs created from this template.
44 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
46 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
48 // Specification of the desired behavior of the job.
49 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
51 Spec batchv1.JobSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
55 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
57 // CronJob represents the configuration of a single cron job.
59 metav1.TypeMeta `json:",inline"`
60 // Standard object's metadata.
61 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
63 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
65 // Specification of the desired behavior of a cron job, including the schedule.
66 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
68 Spec CronJobSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
70 // Current status of a cron job.
71 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
73 Status CronJobStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
76 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
78 // CronJobList is a collection of cron jobs.
79 type CronJobList struct {
80 metav1.TypeMeta `json:",inline"`
82 // Standard list metadata.
83 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
85 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
87 // items is the list of CronJobs.
88 Items []CronJob `json:"items" protobuf:"bytes,2,rep,name=items"`
91 // CronJobSpec describes how the job execution will look like and when it will actually run.
92 type CronJobSpec struct {
94 // The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
95 Schedule string `json:"schedule" protobuf:"bytes,1,opt,name=schedule"`
97 // Optional deadline in seconds for starting the job if it misses scheduled
98 // time for any reason. Missed jobs executions will be counted as failed ones.
100 StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty" protobuf:"varint,2,opt,name=startingDeadlineSeconds"`
102 // Specifies how to treat concurrent executions of a Job.
104 // - "Allow" (default): allows CronJobs to run concurrently;
105 // - "Forbid": forbids concurrent runs, skipping next run if previous run hasn't finished yet;
106 // - "Replace": cancels currently running job and replaces it with a new one
108 ConcurrencyPolicy ConcurrencyPolicy `json:"concurrencyPolicy,omitempty" protobuf:"bytes,3,opt,name=concurrencyPolicy,casttype=ConcurrencyPolicy"`
110 // This flag tells the controller to suspend subsequent executions, it does
111 // not apply to already started executions. Defaults to false.
113 Suspend *bool `json:"suspend,omitempty" protobuf:"varint,4,opt,name=suspend"`
115 // Specifies the job that will be created when executing a CronJob.
116 JobTemplate JobTemplateSpec `json:"jobTemplate" protobuf:"bytes,5,opt,name=jobTemplate"`
118 // The number of successful finished jobs to retain.
119 // This is a pointer to distinguish between explicit zero and not specified.
122 SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty" protobuf:"varint,6,opt,name=successfulJobsHistoryLimit"`
124 // The number of failed finished jobs to retain.
125 // This is a pointer to distinguish between explicit zero and not specified.
128 FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty" protobuf:"varint,7,opt,name=failedJobsHistoryLimit"`
131 // ConcurrencyPolicy describes how the job will be handled.
132 // Only one of the following concurrent policies may be specified.
133 // If none of the following policies is specified, the default one
134 // is AllowConcurrent.
135 type ConcurrencyPolicy string
138 // AllowConcurrent allows CronJobs to run concurrently.
139 AllowConcurrent ConcurrencyPolicy = "Allow"
141 // ForbidConcurrent forbids concurrent runs, skipping next run if previous
142 // hasn't finished yet.
143 ForbidConcurrent ConcurrencyPolicy = "Forbid"
145 // ReplaceConcurrent cancels currently running job and replaces it with a new one.
146 ReplaceConcurrent ConcurrencyPolicy = "Replace"
149 // CronJobStatus represents the current state of a cron job.
150 type CronJobStatus struct {
151 // A list of pointers to currently running jobs.
153 Active []v1.ObjectReference `json:"active,omitempty" protobuf:"bytes,1,rep,name=active"`
155 // Information when was the last time the job was successfully scheduled.
157 LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty" protobuf:"bytes,4,opt,name=lastScheduleTime"`