2 Copyright 2016 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.
21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
25 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
27 // Job represents the configuration of a single job.
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 // Specification of the desired behavior of a job.
36 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
38 Spec JobSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
40 // Current status of a job.
41 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
43 Status JobStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
46 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
48 // JobList is a collection of jobs.
50 metav1.TypeMeta `json:",inline"`
51 // Standard list metadata.
52 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
54 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
56 // items is the list of Jobs.
57 Items []Job `json:"items" protobuf:"bytes,2,rep,name=items"`
60 // JobSpec describes how the job execution will look like.
63 // Specifies the maximum desired number of pods the job should
64 // run at any given time. The actual number of pods running in steady state will
65 // be less than this number when ((.spec.completions - .status.successful) < .spec.parallelism),
66 // i.e. when the work left to do is less than max parallelism.
67 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/
69 Parallelism *int32 `json:"parallelism,omitempty" protobuf:"varint,1,opt,name=parallelism"`
71 // Specifies the desired number of successfully finished pods the
72 // job should be run with. Setting to nil means that the success of any
73 // pod signals the success of all pods, and allows parallelism to have any positive
74 // value. Setting to 1 means that parallelism is limited to 1 and the success of that
75 // pod signals the success of the job.
76 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/
78 Completions *int32 `json:"completions,omitempty" protobuf:"varint,2,opt,name=completions"`
80 // Specifies the duration in seconds relative to the startTime that the job may be active
81 // before the system tries to terminate it; value must be positive integer
83 ActiveDeadlineSeconds *int64 `json:"activeDeadlineSeconds,omitempty" protobuf:"varint,3,opt,name=activeDeadlineSeconds"`
85 // Specifies the number of retries before marking this job failed.
88 BackoffLimit *int32 `json:"backoffLimit,omitempty" protobuf:"varint,7,opt,name=backoffLimit"`
90 // TODO enabled it when https://github.com/kubernetes/kubernetes/issues/28486 has been fixed
91 // Optional number of failed pods to retain.
93 // FailedPodsLimit *int32 `json:"failedPodsLimit,omitempty" protobuf:"varint,9,opt,name=failedPodsLimit"`
95 // A label query over pods that should match the pod count.
96 // Normally, the system sets this field for you.
97 // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
99 Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,4,opt,name=selector"`
101 // manualSelector controls generation of pod labels and pod selectors.
102 // Leave `manualSelector` unset unless you are certain what you are doing.
103 // When false or unset, the system pick labels unique to this job
104 // and appends those labels to the pod template. When true,
105 // the user is responsible for picking unique labels and specifying
106 // the selector. Failure to pick a unique label may cause this
107 // and other jobs to not function correctly. However, You may see
108 // `manualSelector=true` in jobs that were created with the old `extensions/v1beta1`
110 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#specifying-your-own-pod-selector
112 ManualSelector *bool `json:"manualSelector,omitempty" protobuf:"varint,5,opt,name=manualSelector"`
114 // Describes the pod that will be created when executing a job.
115 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/
116 Template v1.PodTemplateSpec `json:"template" protobuf:"bytes,6,opt,name=template"`
118 // ttlSecondsAfterFinished limits the lifetime of a Job that has finished
119 // execution (either Complete or Failed). If this field is set,
120 // ttlSecondsAfterFinished after the Job finishes, it is eligible to be
121 // automatically deleted. When the Job is being deleted, its lifecycle
122 // guarantees (e.g. finalizers) will be honored. If this field is unset,
123 // the Job won't be automatically deleted. If this field is set to zero,
124 // the Job becomes eligible to be deleted immediately after it finishes.
125 // This field is alpha-level and is only honored by servers that enable the
126 // TTLAfterFinished feature.
128 TTLSecondsAfterFinished *int32 `json:"ttlSecondsAfterFinished,omitempty" protobuf:"varint,8,opt,name=ttlSecondsAfterFinished"`
131 // JobStatus represents the current state of a Job.
132 type JobStatus struct {
133 // The latest available observations of an object's current state.
134 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/
136 // +patchMergeKey=type
137 // +patchStrategy=merge
138 Conditions []JobCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
140 // Represents time when the job was acknowledged by the job controller.
141 // It is not guaranteed to be set in happens-before order across separate operations.
142 // It is represented in RFC3339 form and is in UTC.
144 StartTime *metav1.Time `json:"startTime,omitempty" protobuf:"bytes,2,opt,name=startTime"`
146 // Represents time when the job was completed. It is not guaranteed to
147 // be set in happens-before order across separate operations.
148 // It is represented in RFC3339 form and is in UTC.
150 CompletionTime *metav1.Time `json:"completionTime,omitempty" protobuf:"bytes,3,opt,name=completionTime"`
152 // The number of actively running pods.
154 Active int32 `json:"active,omitempty" protobuf:"varint,4,opt,name=active"`
156 // The number of pods which reached phase Succeeded.
158 Succeeded int32 `json:"succeeded,omitempty" protobuf:"varint,5,opt,name=succeeded"`
160 // The number of pods which reached phase Failed.
162 Failed int32 `json:"failed,omitempty" protobuf:"varint,6,opt,name=failed"`
165 type JobConditionType string
167 // These are valid conditions of a job.
169 // JobComplete means the job has completed its execution.
170 JobComplete JobConditionType = "Complete"
171 // JobFailed means the job has failed its execution.
172 JobFailed JobConditionType = "Failed"
175 // JobCondition describes current state of a job.
176 type JobCondition struct {
177 // Type of job condition, Complete or Failed.
178 Type JobConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=JobConditionType"`
179 // Status of the condition, one of True, False, Unknown.
180 Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"`
181 // Last time the condition was checked.
183 LastProbeTime metav1.Time `json:"lastProbeTime,omitempty" protobuf:"bytes,3,opt,name=lastProbeTime"`
184 // Last time the condition transit from one status to another.
186 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,4,opt,name=lastTransitionTime"`
187 // (brief) reason for the condition's last transition.
189 Reason string `json:"reason,omitempty" protobuf:"bytes,5,opt,name=reason"`
190 // Human readable message indicating details about last transition.
192 Message string `json:"message,omitempty" protobuf:"bytes,6,opt,name=message"`