PageRenderTime 38ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/rescheduler/vendor/k8s.io/client-go/pkg/apis/batch/v2alpha1/types.go

https://gitlab.com/unofficial-mirrors/kubernetes-contrib
Go | 282 lines | 82 code | 47 blank | 153 comment | 0 complexity | 00a35ffd3c54f0678eb82b3c75031174 MD5 | raw file
  1. /*
  2. Copyright 2016 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package v2alpha1
  14. import (
  15. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  16. "k8s.io/client-go/pkg/api/v1"
  17. )
  18. // +genclient=true
  19. // Job represents the configuration of a single job.
  20. type Job struct {
  21. metav1.TypeMeta `json:",inline"`
  22. // Standard object's metadata.
  23. // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
  24. // +optional
  25. metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
  26. // Spec is a structure defining the expected behavior of a job.
  27. // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
  28. // +optional
  29. Spec JobSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
  30. // Status is a structure describing current status of a job.
  31. // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
  32. // +optional
  33. Status JobStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
  34. }
  35. // JobList is a collection of jobs.
  36. type JobList struct {
  37. metav1.TypeMeta `json:",inline"`
  38. // Standard list metadata
  39. // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
  40. // +optional
  41. metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
  42. // Items is the list of Job.
  43. Items []Job `json:"items" protobuf:"bytes,2,rep,name=items"`
  44. }
  45. // JobTemplate describes a template for creating copies of a predefined pod.
  46. type JobTemplate struct {
  47. metav1.TypeMeta `json:",inline"`
  48. // Standard object's metadata.
  49. // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
  50. // +optional
  51. metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
  52. // Template defines jobs that will be created from this template
  53. // http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
  54. // +optional
  55. Template JobTemplateSpec `json:"template,omitempty" protobuf:"bytes,2,opt,name=template"`
  56. }
  57. // JobTemplateSpec describes the data a Job should have when created from a template
  58. type JobTemplateSpec struct {
  59. // Standard object's metadata of the jobs created from this template.
  60. // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
  61. // +optional
  62. metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
  63. // Specification of the desired behavior of the job.
  64. // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
  65. // +optional
  66. Spec JobSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
  67. }
  68. // JobSpec describes how the job execution will look like.
  69. type JobSpec struct {
  70. // Parallelism specifies the maximum desired number of pods the job should
  71. // run at any given time. The actual number of pods running in steady state will
  72. // be less than this number when ((.spec.completions - .status.successful) < .spec.parallelism),
  73. // i.e. when the work left to do is less than max parallelism.
  74. // More info: http://kubernetes.io/docs/user-guide/jobs
  75. // +optional
  76. Parallelism *int32 `json:"parallelism,omitempty" protobuf:"varint,1,opt,name=parallelism"`
  77. // Completions specifies the desired number of successfully finished pods the
  78. // job should be run with. Setting to nil means that the success of any
  79. // pod signals the success of all pods, and allows parallelism to have any positive
  80. // value. Setting to 1 means that parallelism is limited to 1 and the success of that
  81. // pod signals the success of the job.
  82. // More info: http://kubernetes.io/docs/user-guide/jobs
  83. // +optional
  84. Completions *int32 `json:"completions,omitempty" protobuf:"varint,2,opt,name=completions"`
  85. // Optional duration in seconds relative to the startTime that the job may be active
  86. // before the system tries to terminate it; value must be positive integer
  87. // +optional
  88. ActiveDeadlineSeconds *int64 `json:"activeDeadlineSeconds,omitempty" protobuf:"varint,3,opt,name=activeDeadlineSeconds"`
  89. // Selector is a label query over pods that should match the pod count.
  90. // Normally, the system sets this field for you.
  91. // More info: http://kubernetes.io/docs/user-guide/labels#label-selectors
  92. // +optional
  93. Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,4,opt,name=selector"`
  94. // ManualSelector controls generation of pod labels and pod selectors.
  95. // Leave `manualSelector` unset unless you are certain what you are doing.
  96. // When false or unset, the system pick labels unique to this job
  97. // and appends those labels to the pod template. When true,
  98. // the user is responsible for picking unique labels and specifying
  99. // the selector. Failure to pick a unique label may cause this
  100. // and other jobs to not function correctly. However, You may see
  101. // `manualSelector=true` in jobs that were created with the old `extensions/v1beta1`
  102. // API.
  103. // More info: http://releases.k8s.io/HEAD/docs/design/selector-generation.md
  104. // +optional
  105. ManualSelector *bool `json:"manualSelector,omitempty" protobuf:"varint,5,opt,name=manualSelector"`
  106. // Template is the object that describes the pod that will be created when
  107. // executing a job.
  108. // More info: http://kubernetes.io/docs/user-guide/jobs
  109. Template v1.PodTemplateSpec `json:"template" protobuf:"bytes,6,opt,name=template"`
  110. }
  111. // JobStatus represents the current state of a Job.
  112. type JobStatus struct {
  113. // Conditions represent the latest available observations of an object's current state.
  114. // More info: http://kubernetes.io/docs/user-guide/jobs
  115. // +optional
  116. Conditions []JobCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
  117. // StartTime represents time when the job was acknowledged by the Job Manager.
  118. // It is not guaranteed to be set in happens-before order across separate operations.
  119. // It is represented in RFC3339 form and is in UTC.
  120. // +optional
  121. StartTime *metav1.Time `json:"startTime,omitempty" protobuf:"bytes,2,opt,name=startTime"`
  122. // CompletionTime represents time when the job was completed. It is not guaranteed to
  123. // be set in happens-before order across separate operations.
  124. // It is represented in RFC3339 form and is in UTC.
  125. // +optional
  126. CompletionTime *metav1.Time `json:"completionTime,omitempty" protobuf:"bytes,3,opt,name=completionTime"`
  127. // Active is the number of actively running pods.
  128. // +optional
  129. Active int32 `json:"active,omitempty" protobuf:"varint,4,opt,name=active"`
  130. // Succeeded is the number of pods which reached Phase Succeeded.
  131. // +optional
  132. Succeeded int32 `json:"succeeded,omitempty" protobuf:"varint,5,opt,name=succeeded"`
  133. // Failed is the number of pods which reached Phase Failed.
  134. // +optional
  135. Failed int32 `json:"failed,omitempty" protobuf:"varint,6,opt,name=failed"`
  136. }
  137. type JobConditionType string
  138. // These are valid conditions of a job.
  139. const (
  140. // JobComplete means the job has completed its execution.
  141. JobComplete JobConditionType = "Complete"
  142. // JobFailed means the job has failed its execution.
  143. JobFailed JobConditionType = "Failed"
  144. )
  145. // JobCondition describes current state of a job.
  146. type JobCondition struct {
  147. // Type of job condition, Complete or Failed.
  148. Type JobConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=JobConditionType"`
  149. // Status of the condition, one of True, False, Unknown.
  150. Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/kubernetes/pkg/api/v1.ConditionStatus"`
  151. // Last time the condition was checked.
  152. // +optional
  153. LastProbeTime metav1.Time `json:"lastProbeTime,omitempty" protobuf:"bytes,3,opt,name=lastProbeTime"`
  154. // Last time the condition transit from one status to another.
  155. // +optional
  156. LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,4,opt,name=lastTransitionTime"`
  157. // (brief) reason for the condition's last transition.
  158. // +optional
  159. Reason string `json:"reason,omitempty" protobuf:"bytes,5,opt,name=reason"`
  160. // Human readable message indicating details about last transition.
  161. // +optional
  162. Message string `json:"message,omitempty" protobuf:"bytes,6,opt,name=message"`
  163. }
  164. // +genclient=true
  165. // CronJob represents the configuration of a single cron job.
  166. type CronJob struct {
  167. metav1.TypeMeta `json:",inline"`
  168. // Standard object's metadata.
  169. // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
  170. // +optional
  171. metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
  172. // Spec is a structure defining the expected behavior of a job, including the schedule.
  173. // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
  174. // +optional
  175. Spec CronJobSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
  176. // Status is a structure describing current status of a job.
  177. // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
  178. // +optional
  179. Status CronJobStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
  180. }
  181. // CronJobList is a collection of cron jobs.
  182. type CronJobList struct {
  183. metav1.TypeMeta `json:",inline"`
  184. // Standard list metadata
  185. // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
  186. // +optional
  187. metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
  188. // Items is the list of CronJob.
  189. Items []CronJob `json:"items" protobuf:"bytes,2,rep,name=items"`
  190. }
  191. // CronJobSpec describes how the job execution will look like and when it will actually run.
  192. type CronJobSpec struct {
  193. // Schedule contains the schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
  194. Schedule string `json:"schedule" protobuf:"bytes,1,opt,name=schedule"`
  195. // Optional deadline in seconds for starting the job if it misses scheduled
  196. // time for any reason. Missed jobs executions will be counted as failed ones.
  197. // +optional
  198. StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty" protobuf:"varint,2,opt,name=startingDeadlineSeconds"`
  199. // ConcurrencyPolicy specifies how to treat concurrent executions of a Job.
  200. // +optional
  201. ConcurrencyPolicy ConcurrencyPolicy `json:"concurrencyPolicy,omitempty" protobuf:"bytes,3,opt,name=concurrencyPolicy,casttype=ConcurrencyPolicy"`
  202. // Suspend flag tells the controller to suspend subsequent executions, it does
  203. // not apply to already started executions. Defaults to false.
  204. // +optional
  205. Suspend *bool `json:"suspend,omitempty" protobuf:"varint,4,opt,name=suspend"`
  206. // JobTemplate is the object that describes the job that will be created when
  207. // executing a CronJob.
  208. JobTemplate JobTemplateSpec `json:"jobTemplate" protobuf:"bytes,5,opt,name=jobTemplate"`
  209. }
  210. // ConcurrencyPolicy describes how the job will be handled.
  211. // Only one of the following concurrent policies may be specified.
  212. // If none of the following policies is specified, the default one
  213. // is AllowConcurrent.
  214. type ConcurrencyPolicy string
  215. const (
  216. // AllowConcurrent allows CronJobs to run concurrently.
  217. AllowConcurrent ConcurrencyPolicy = "Allow"
  218. // ForbidConcurrent forbids concurrent runs, skipping next run if previous
  219. // hasn't finished yet.
  220. ForbidConcurrent ConcurrencyPolicy = "Forbid"
  221. // ReplaceConcurrent cancels currently running job and replaces it with a new one.
  222. ReplaceConcurrent ConcurrencyPolicy = "Replace"
  223. )
  224. // CronJobStatus represents the current state of a cron job.
  225. type CronJobStatus struct {
  226. // Active holds pointers to currently running jobs.
  227. // +optional
  228. Active []v1.ObjectReference `json:"active,omitempty" protobuf:"bytes,1,rep,name=active"`
  229. // LastScheduleTime keeps information of when was the last time the job was successfully scheduled.
  230. // +optional
  231. LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty" protobuf:"bytes,4,opt,name=lastScheduleTime"`
  232. }