blob: 39e07e278ae2e0008dd744700b61c5a90d5cf471 [file] [log] [blame]
Zack Williamse940c7a2019-08-21 14:25:39 -07001/*
2Copyright 2017 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package v1beta2
18
19import (
20 v1 "k8s.io/api/core/v1"
21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22 runtime "k8s.io/apimachinery/pkg/runtime"
23 "k8s.io/apimachinery/pkg/util/intstr"
24)
25
26const (
27 ControllerRevisionHashLabelKey = "controller-revision-hash"
28 StatefulSetRevisionLabel = ControllerRevisionHashLabelKey
29 DeprecatedRollbackTo = "deprecated.deployment.rollback.to"
30 DeprecatedTemplateGeneration = "deprecated.daemonset.template.generation"
31 StatefulSetPodNameLabel = "statefulset.kubernetes.io/pod-name"
32)
33
34// ScaleSpec describes the attributes of a scale subresource
35type ScaleSpec struct {
36 // desired number of instances for the scaled object.
37 // +optional
38 Replicas int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
39}
40
41// ScaleStatus represents the current status of a scale subresource.
42type ScaleStatus struct {
43 // actual number of observed instances of the scaled object.
44 Replicas int32 `json:"replicas" protobuf:"varint,1,opt,name=replicas"`
45
46 // label query over pods that should match the replicas count. More info: http://kubernetes.io/docs/user-guide/labels#label-selectors
47 // +optional
48 Selector map[string]string `json:"selector,omitempty" protobuf:"bytes,2,rep,name=selector"`
49
50 // label selector for pods that should match the replicas count. This is a serializated
51 // version of both map-based and more expressive set-based selectors. This is done to
52 // avoid introspection in the clients. The string will be in the same format as the
53 // query-param syntax. If the target type only supports map-based selectors, both this
54 // field and map-based selector field are populated.
55 // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
56 // +optional
57 TargetSelector string `json:"targetSelector,omitempty" protobuf:"bytes,3,opt,name=targetSelector"`
58}
59
60// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
61
62// Scale represents a scaling request for a resource.
63type Scale struct {
64 metav1.TypeMeta `json:",inline"`
65 // Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata.
66 // +optional
67 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
68
69 // defines the behavior of the scale. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status.
70 // +optional
71 Spec ScaleSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
72
73 // current status of the scale. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status. Read-only.
74 // +optional
75 Status ScaleStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
76}
77
78// +genclient
79// +genclient:method=GetScale,verb=get,subresource=scale,result=Scale
80// +genclient:method=UpdateScale,verb=update,subresource=scale,input=Scale,result=Scale
81// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
82
83// DEPRECATED - This group version of StatefulSet is deprecated by apps/v1/StatefulSet. See the release notes for
84// more information.
85// StatefulSet represents a set of pods with consistent identities.
86// Identities are defined as:
87// - Network: A single stable DNS and hostname.
88// - Storage: As many VolumeClaims as requested.
89// The StatefulSet guarantees that a given network identity will always
90// map to the same storage identity.
91type StatefulSet struct {
92 metav1.TypeMeta `json:",inline"`
93 // +optional
94 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
95
96 // Spec defines the desired identities of pods in this set.
97 // +optional
98 Spec StatefulSetSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
99
100 // Status is the current status of Pods in this StatefulSet. This data
101 // may be out of date by some window of time.
102 // +optional
103 Status StatefulSetStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
104}
105
106// PodManagementPolicyType defines the policy for creating pods under a stateful set.
107type PodManagementPolicyType string
108
109const (
110 // OrderedReadyPodManagement will create pods in strictly increasing order on
111 // scale up and strictly decreasing order on scale down, progressing only when
112 // the previous pod is ready or terminated. At most one pod will be changed
113 // at any time.
114 OrderedReadyPodManagement PodManagementPolicyType = "OrderedReady"
115 // ParallelPodManagement will create and delete pods as soon as the stateful set
116 // replica count is changed, and will not wait for pods to be ready or complete
117 // termination.
118 ParallelPodManagement PodManagementPolicyType = "Parallel"
119)
120
121// StatefulSetUpdateStrategy indicates the strategy that the StatefulSet
122// controller will use to perform updates. It includes any additional parameters
123// necessary to perform the update for the indicated strategy.
124type StatefulSetUpdateStrategy struct {
125 // Type indicates the type of the StatefulSetUpdateStrategy.
126 // Default is RollingUpdate.
127 // +optional
128 Type StatefulSetUpdateStrategyType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type,casttype=StatefulSetStrategyType"`
129 // RollingUpdate is used to communicate parameters when Type is RollingUpdateStatefulSetStrategyType.
130 // +optional
131 RollingUpdate *RollingUpdateStatefulSetStrategy `json:"rollingUpdate,omitempty" protobuf:"bytes,2,opt,name=rollingUpdate"`
132}
133
134// StatefulSetUpdateStrategyType is a string enumeration type that enumerates
135// all possible update strategies for the StatefulSet controller.
136type StatefulSetUpdateStrategyType string
137
138const (
139 // RollingUpdateStatefulSetStrategyType indicates that update will be
140 // applied to all Pods in the StatefulSet with respect to the StatefulSet
141 // ordering constraints. When a scale operation is performed with this
142 // strategy, new Pods will be created from the specification version indicated
143 // by the StatefulSet's updateRevision.
144 RollingUpdateStatefulSetStrategyType = "RollingUpdate"
145 // OnDeleteStatefulSetStrategyType triggers the legacy behavior. Version
146 // tracking and ordered rolling restarts are disabled. Pods are recreated
147 // from the StatefulSetSpec when they are manually deleted. When a scale
148 // operation is performed with this strategy,specification version indicated
149 // by the StatefulSet's currentRevision.
150 OnDeleteStatefulSetStrategyType = "OnDelete"
151)
152
153// RollingUpdateStatefulSetStrategy is used to communicate parameter for RollingUpdateStatefulSetStrategyType.
154type RollingUpdateStatefulSetStrategy struct {
155 // Partition indicates the ordinal at which the StatefulSet should be
156 // partitioned.
157 // Default value is 0.
158 // +optional
159 Partition *int32 `json:"partition,omitempty" protobuf:"varint,1,opt,name=partition"`
160}
161
162// A StatefulSetSpec is the specification of a StatefulSet.
163type StatefulSetSpec struct {
164 // replicas is the desired number of replicas of the given Template.
165 // These are replicas in the sense that they are instantiations of the
166 // same Template, but individual replicas also have a consistent identity.
167 // If unspecified, defaults to 1.
168 // TODO: Consider a rename of this field.
169 // +optional
170 Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
171
172 // selector is a label query over pods that should match the replica count.
173 // It must match the pod template's labels.
174 // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
175 Selector *metav1.LabelSelector `json:"selector" protobuf:"bytes,2,opt,name=selector"`
176
177 // template is the object that describes the pod that will be created if
178 // insufficient replicas are detected. Each pod stamped out by the StatefulSet
179 // will fulfill this Template, but have a unique identity from the rest
180 // of the StatefulSet.
181 Template v1.PodTemplateSpec `json:"template" protobuf:"bytes,3,opt,name=template"`
182
183 // volumeClaimTemplates is a list of claims that pods are allowed to reference.
184 // The StatefulSet controller is responsible for mapping network identities to
185 // claims in a way that maintains the identity of a pod. Every claim in
186 // this list must have at least one matching (by name) volumeMount in one
187 // container in the template. A claim in this list takes precedence over
188 // any volumes in the template, with the same name.
189 // TODO: Define the behavior if a claim already exists with the same name.
190 // +optional
191 VolumeClaimTemplates []v1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty" protobuf:"bytes,4,rep,name=volumeClaimTemplates"`
192
193 // serviceName is the name of the service that governs this StatefulSet.
194 // This service must exist before the StatefulSet, and is responsible for
195 // the network identity of the set. Pods get DNS/hostnames that follow the
196 // pattern: pod-specific-string.serviceName.default.svc.cluster.local
197 // where "pod-specific-string" is managed by the StatefulSet controller.
198 ServiceName string `json:"serviceName" protobuf:"bytes,5,opt,name=serviceName"`
199
200 // podManagementPolicy controls how pods are created during initial scale up,
201 // when replacing pods on nodes, or when scaling down. The default policy is
202 // `OrderedReady`, where pods are created in increasing order (pod-0, then
203 // pod-1, etc) and the controller will wait until each pod is ready before
204 // continuing. When scaling down, the pods are removed in the opposite order.
205 // The alternative policy is `Parallel` which will create pods in parallel
206 // to match the desired scale without waiting, and on scale down will delete
207 // all pods at once.
208 // +optional
209 PodManagementPolicy PodManagementPolicyType `json:"podManagementPolicy,omitempty" protobuf:"bytes,6,opt,name=podManagementPolicy,casttype=PodManagementPolicyType"`
210
211 // updateStrategy indicates the StatefulSetUpdateStrategy that will be
212 // employed to update Pods in the StatefulSet when a revision is made to
213 // Template.
214 UpdateStrategy StatefulSetUpdateStrategy `json:"updateStrategy,omitempty" protobuf:"bytes,7,opt,name=updateStrategy"`
215
216 // revisionHistoryLimit is the maximum number of revisions that will
217 // be maintained in the StatefulSet's revision history. The revision history
218 // consists of all revisions not represented by a currently applied
219 // StatefulSetSpec version. The default value is 10.
220 RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,8,opt,name=revisionHistoryLimit"`
221}
222
223// StatefulSetStatus represents the current state of a StatefulSet.
224type StatefulSetStatus struct {
225 // observedGeneration is the most recent generation observed for this StatefulSet. It corresponds to the
226 // StatefulSet's generation, which is updated on mutation by the API Server.
227 // +optional
228 ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"`
229
230 // replicas is the number of Pods created by the StatefulSet controller.
231 Replicas int32 `json:"replicas" protobuf:"varint,2,opt,name=replicas"`
232
233 // readyReplicas is the number of Pods created by the StatefulSet controller that have a Ready Condition.
234 ReadyReplicas int32 `json:"readyReplicas,omitempty" protobuf:"varint,3,opt,name=readyReplicas"`
235
236 // currentReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version
237 // indicated by currentRevision.
238 CurrentReplicas int32 `json:"currentReplicas,omitempty" protobuf:"varint,4,opt,name=currentReplicas"`
239
240 // updatedReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version
241 // indicated by updateRevision.
242 UpdatedReplicas int32 `json:"updatedReplicas,omitempty" protobuf:"varint,5,opt,name=updatedReplicas"`
243
244 // currentRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the
245 // sequence [0,currentReplicas).
246 CurrentRevision string `json:"currentRevision,omitempty" protobuf:"bytes,6,opt,name=currentRevision"`
247
248 // updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence
249 // [replicas-updatedReplicas,replicas)
250 UpdateRevision string `json:"updateRevision,omitempty" protobuf:"bytes,7,opt,name=updateRevision"`
251
252 // collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller
253 // uses this field as a collision avoidance mechanism when it needs to create the name for the
254 // newest ControllerRevision.
255 // +optional
256 CollisionCount *int32 `json:"collisionCount,omitempty" protobuf:"varint,9,opt,name=collisionCount"`
257
258 // Represents the latest available observations of a statefulset's current state.
259 // +optional
260 // +patchMergeKey=type
261 // +patchStrategy=merge
262 Conditions []StatefulSetCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,10,rep,name=conditions"`
263}
264
265type StatefulSetConditionType string
266
267// StatefulSetCondition describes the state of a statefulset at a certain point.
268type StatefulSetCondition struct {
269 // Type of statefulset condition.
270 Type StatefulSetConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=StatefulSetConditionType"`
271 // Status of the condition, one of True, False, Unknown.
272 Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"`
273 // Last time the condition transitioned from one status to another.
274 // +optional
275 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"`
276 // The reason for the condition's last transition.
277 // +optional
278 Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
279 // A human readable message indicating details about the transition.
280 // +optional
281 Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
282}
283
284// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
285
286// StatefulSetList is a collection of StatefulSets.
287type StatefulSetList struct {
288 metav1.TypeMeta `json:",inline"`
289 // +optional
290 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
291 Items []StatefulSet `json:"items" protobuf:"bytes,2,rep,name=items"`
292}
293
294// +genclient
295// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
296
297// DEPRECATED - This group version of Deployment is deprecated by apps/v1/Deployment. See the release notes for
298// more information.
299// Deployment enables declarative updates for Pods and ReplicaSets.
300type Deployment struct {
301 metav1.TypeMeta `json:",inline"`
302 // Standard object metadata.
303 // +optional
304 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
305
306 // Specification of the desired behavior of the Deployment.
307 // +optional
308 Spec DeploymentSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
309
310 // Most recently observed status of the Deployment.
311 // +optional
312 Status DeploymentStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
313}
314
315// DeploymentSpec is the specification of the desired behavior of the Deployment.
316type DeploymentSpec struct {
317 // Number of desired pods. This is a pointer to distinguish between explicit
318 // zero and not specified. Defaults to 1.
319 // +optional
320 Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
321
322 // Label selector for pods. Existing ReplicaSets whose pods are
323 // selected by this will be the ones affected by this deployment.
324 // It must match the pod template's labels.
325 Selector *metav1.LabelSelector `json:"selector" protobuf:"bytes,2,opt,name=selector"`
326
327 // Template describes the pods that will be created.
328 Template v1.PodTemplateSpec `json:"template" protobuf:"bytes,3,opt,name=template"`
329
330 // The deployment strategy to use to replace existing pods with new ones.
331 // +optional
332 // +patchStrategy=retainKeys
333 Strategy DeploymentStrategy `json:"strategy,omitempty" patchStrategy:"retainKeys" protobuf:"bytes,4,opt,name=strategy"`
334
335 // Minimum number of seconds for which a newly created pod should be ready
336 // without any of its container crashing, for it to be considered available.
337 // Defaults to 0 (pod will be considered available as soon as it is ready)
338 // +optional
339 MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,5,opt,name=minReadySeconds"`
340
341 // The number of old ReplicaSets to retain to allow rollback.
342 // This is a pointer to distinguish between explicit zero and not specified.
343 // Defaults to 10.
344 // +optional
345 RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,6,opt,name=revisionHistoryLimit"`
346
347 // Indicates that the deployment is paused.
348 // +optional
349 Paused bool `json:"paused,omitempty" protobuf:"varint,7,opt,name=paused"`
350
351 // The maximum time in seconds for a deployment to make progress before it
352 // is considered to be failed. The deployment controller will continue to
353 // process failed deployments and a condition with a ProgressDeadlineExceeded
354 // reason will be surfaced in the deployment status. Note that progress will
355 // not be estimated during the time a deployment is paused. Defaults to 600s.
356 ProgressDeadlineSeconds *int32 `json:"progressDeadlineSeconds,omitempty" protobuf:"varint,9,opt,name=progressDeadlineSeconds"`
357}
358
359const (
360 // DefaultDeploymentUniqueLabelKey is the default key of the selector that is added
361 // to existing ReplicaSets (and label key that is added to its pods) to prevent the existing ReplicaSets
362 // to select new pods (and old pods being select by new ReplicaSet).
363 DefaultDeploymentUniqueLabelKey string = "pod-template-hash"
364)
365
366// DeploymentStrategy describes how to replace existing pods with new ones.
367type DeploymentStrategy struct {
368 // Type of deployment. Can be "Recreate" or "RollingUpdate". Default is RollingUpdate.
369 // +optional
370 Type DeploymentStrategyType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type,casttype=DeploymentStrategyType"`
371
372 // Rolling update config params. Present only if DeploymentStrategyType =
373 // RollingUpdate.
374 //---
375 // TODO: Update this to follow our convention for oneOf, whatever we decide it
376 // to be.
377 // +optional
378 RollingUpdate *RollingUpdateDeployment `json:"rollingUpdate,omitempty" protobuf:"bytes,2,opt,name=rollingUpdate"`
379}
380
381type DeploymentStrategyType string
382
383const (
384 // Kill all existing pods before creating new ones.
385 RecreateDeploymentStrategyType DeploymentStrategyType = "Recreate"
386
387 // Replace the old ReplicaSets by new one using rolling update i.e gradually scale down the old ReplicaSets and scale up the new one.
388 RollingUpdateDeploymentStrategyType DeploymentStrategyType = "RollingUpdate"
389)
390
391// Spec to control the desired behavior of rolling update.
392type RollingUpdateDeployment struct {
393 // The maximum number of pods that can be unavailable during the update.
394 // Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
395 // Absolute number is calculated from percentage by rounding down.
396 // This can not be 0 if MaxSurge is 0.
397 // Defaults to 25%.
398 // Example: when this is set to 30%, the old ReplicaSet can be scaled down to 70% of desired pods
399 // immediately when the rolling update starts. Once new pods are ready, old ReplicaSet
400 // can be scaled down further, followed by scaling up the new ReplicaSet, ensuring
401 // that the total number of pods available at all times during the update is at
402 // least 70% of desired pods.
403 // +optional
404 MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty" protobuf:"bytes,1,opt,name=maxUnavailable"`
405
406 // The maximum number of pods that can be scheduled above the desired number of
407 // pods.
408 // Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
409 // This can not be 0 if MaxUnavailable is 0.
410 // Absolute number is calculated from percentage by rounding up.
411 // Defaults to 25%.
412 // Example: when this is set to 30%, the new ReplicaSet can be scaled up immediately when
413 // the rolling update starts, such that the total number of old and new pods do not exceed
414 // 130% of desired pods. Once old pods have been killed,
415 // new ReplicaSet can be scaled up further, ensuring that total number of pods running
416 // at any time during the update is at most 130% of desired pods.
417 // +optional
418 MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty" protobuf:"bytes,2,opt,name=maxSurge"`
419}
420
421// DeploymentStatus is the most recently observed status of the Deployment.
422type DeploymentStatus struct {
423 // The generation observed by the deployment controller.
424 // +optional
425 ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"`
426
427 // Total number of non-terminated pods targeted by this deployment (their labels match the selector).
428 // +optional
429 Replicas int32 `json:"replicas,omitempty" protobuf:"varint,2,opt,name=replicas"`
430
431 // Total number of non-terminated pods targeted by this deployment that have the desired template spec.
432 // +optional
433 UpdatedReplicas int32 `json:"updatedReplicas,omitempty" protobuf:"varint,3,opt,name=updatedReplicas"`
434
435 // Total number of ready pods targeted by this deployment.
436 // +optional
437 ReadyReplicas int32 `json:"readyReplicas,omitempty" protobuf:"varint,7,opt,name=readyReplicas"`
438
439 // Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.
440 // +optional
441 AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,4,opt,name=availableReplicas"`
442
443 // Total number of unavailable pods targeted by this deployment. This is the total number of
444 // pods that are still required for the deployment to have 100% available capacity. They may
445 // either be pods that are running but not yet available or pods that still have not been created.
446 // +optional
447 UnavailableReplicas int32 `json:"unavailableReplicas,omitempty" protobuf:"varint,5,opt,name=unavailableReplicas"`
448
449 // Represents the latest available observations of a deployment's current state.
450 // +patchMergeKey=type
451 // +patchStrategy=merge
452 Conditions []DeploymentCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,6,rep,name=conditions"`
453
454 // Count of hash collisions for the Deployment. The Deployment controller uses this
455 // field as a collision avoidance mechanism when it needs to create the name for the
456 // newest ReplicaSet.
457 // +optional
458 CollisionCount *int32 `json:"collisionCount,omitempty" protobuf:"varint,8,opt,name=collisionCount"`
459}
460
461type DeploymentConditionType string
462
463// These are valid conditions of a deployment.
464const (
465 // Available means the deployment is available, ie. at least the minimum available
466 // replicas required are up and running for at least minReadySeconds.
467 DeploymentAvailable DeploymentConditionType = "Available"
468 // Progressing means the deployment is progressing. Progress for a deployment is
469 // considered when a new replica set is created or adopted, and when new pods scale
470 // up or old pods scale down. Progress is not estimated for paused deployments or
471 // when progressDeadlineSeconds is not specified.
472 DeploymentProgressing DeploymentConditionType = "Progressing"
473 // ReplicaFailure is added in a deployment when one of its pods fails to be created
474 // or deleted.
475 DeploymentReplicaFailure DeploymentConditionType = "ReplicaFailure"
476)
477
478// DeploymentCondition describes the state of a deployment at a certain point.
479type DeploymentCondition struct {
480 // Type of deployment condition.
481 Type DeploymentConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=DeploymentConditionType"`
482 // Status of the condition, one of True, False, Unknown.
483 Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"`
484 // The last time this condition was updated.
485 LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty" protobuf:"bytes,6,opt,name=lastUpdateTime"`
486 // Last time the condition transitioned from one status to another.
487 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,7,opt,name=lastTransitionTime"`
488 // The reason for the condition's last transition.
489 Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
490 // A human readable message indicating details about the transition.
491 Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
492}
493
494// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
495
496// DeploymentList is a list of Deployments.
497type DeploymentList struct {
498 metav1.TypeMeta `json:",inline"`
499 // Standard list metadata.
500 // +optional
501 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
502
503 // Items is the list of Deployments.
504 Items []Deployment `json:"items" protobuf:"bytes,2,rep,name=items"`
505}
506
507// DaemonSetUpdateStrategy is a struct used to control the update strategy for a DaemonSet.
508type DaemonSetUpdateStrategy struct {
509 // Type of daemon set update. Can be "RollingUpdate" or "OnDelete". Default is RollingUpdate.
510 // +optional
511 Type DaemonSetUpdateStrategyType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type"`
512
513 // Rolling update config params. Present only if type = "RollingUpdate".
514 //---
515 // TODO: Update this to follow our convention for oneOf, whatever we decide it
516 // to be. Same as Deployment `strategy.rollingUpdate`.
517 // See https://github.com/kubernetes/kubernetes/issues/35345
518 // +optional
519 RollingUpdate *RollingUpdateDaemonSet `json:"rollingUpdate,omitempty" protobuf:"bytes,2,opt,name=rollingUpdate"`
520}
521
522type DaemonSetUpdateStrategyType string
523
524const (
525 // Replace the old daemons by new ones using rolling update i.e replace them on each node one after the other.
526 RollingUpdateDaemonSetStrategyType DaemonSetUpdateStrategyType = "RollingUpdate"
527
528 // Replace the old daemons only when it's killed
529 OnDeleteDaemonSetStrategyType DaemonSetUpdateStrategyType = "OnDelete"
530)
531
532// Spec to control the desired behavior of daemon set rolling update.
533type RollingUpdateDaemonSet struct {
534 // The maximum number of DaemonSet pods that can be unavailable during the
535 // update. Value can be an absolute number (ex: 5) or a percentage of total
536 // number of DaemonSet pods at the start of the update (ex: 10%). Absolute
537 // number is calculated from percentage by rounding up.
538 // This cannot be 0.
539 // Default value is 1.
540 // Example: when this is set to 30%, at most 30% of the total number of nodes
541 // that should be running the daemon pod (i.e. status.desiredNumberScheduled)
542 // can have their pods stopped for an update at any given
543 // time. The update starts by stopping at most 30% of those DaemonSet pods
544 // and then brings up new DaemonSet pods in their place. Once the new pods
545 // are available, it then proceeds onto other DaemonSet pods, thus ensuring
546 // that at least 70% of original number of DaemonSet pods are available at
547 // all times during the update.
548 // +optional
549 MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty" protobuf:"bytes,1,opt,name=maxUnavailable"`
550}
551
552// DaemonSetSpec is the specification of a daemon set.
553type DaemonSetSpec struct {
554 // A label query over pods that are managed by the daemon set.
555 // Must match in order to be controlled.
556 // It must match the pod template's labels.
557 // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
558 Selector *metav1.LabelSelector `json:"selector" protobuf:"bytes,1,opt,name=selector"`
559
560 // An object that describes the pod that will be created.
561 // The DaemonSet will create exactly one copy of this pod on every node
562 // that matches the template's node selector (or on every node if no node
563 // selector is specified).
564 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template
565 Template v1.PodTemplateSpec `json:"template" protobuf:"bytes,2,opt,name=template"`
566
567 // An update strategy to replace existing DaemonSet pods with new pods.
568 // +optional
569 UpdateStrategy DaemonSetUpdateStrategy `json:"updateStrategy,omitempty" protobuf:"bytes,3,opt,name=updateStrategy"`
570
571 // The minimum number of seconds for which a newly created DaemonSet pod should
572 // be ready without any of its container crashing, for it to be considered
573 // available. Defaults to 0 (pod will be considered available as soon as it
574 // is ready).
575 // +optional
576 MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,4,opt,name=minReadySeconds"`
577
578 // The number of old history to retain to allow rollback.
579 // This is a pointer to distinguish between explicit zero and not specified.
580 // Defaults to 10.
581 // +optional
582 RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,6,opt,name=revisionHistoryLimit"`
583}
584
585// DaemonSetStatus represents the current status of a daemon set.
586type DaemonSetStatus struct {
587 // The number of nodes that are running at least 1
588 // daemon pod and are supposed to run the daemon pod.
589 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/
590 CurrentNumberScheduled int32 `json:"currentNumberScheduled" protobuf:"varint,1,opt,name=currentNumberScheduled"`
591
592 // The number of nodes that are running the daemon pod, but are
593 // not supposed to run the daemon pod.
594 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/
595 NumberMisscheduled int32 `json:"numberMisscheduled" protobuf:"varint,2,opt,name=numberMisscheduled"`
596
597 // The total number of nodes that should be running the daemon
598 // pod (including nodes correctly running the daemon pod).
599 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/
600 DesiredNumberScheduled int32 `json:"desiredNumberScheduled" protobuf:"varint,3,opt,name=desiredNumberScheduled"`
601
602 // The number of nodes that should be running the daemon pod and have one
603 // or more of the daemon pod running and ready.
604 NumberReady int32 `json:"numberReady" protobuf:"varint,4,opt,name=numberReady"`
605
606 // The most recent generation observed by the daemon set controller.
607 // +optional
608 ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,5,opt,name=observedGeneration"`
609
610 // The total number of nodes that are running updated daemon pod
611 // +optional
612 UpdatedNumberScheduled int32 `json:"updatedNumberScheduled,omitempty" protobuf:"varint,6,opt,name=updatedNumberScheduled"`
613
614 // The number of nodes that should be running the
615 // daemon pod and have one or more of the daemon pod running and
616 // available (ready for at least spec.minReadySeconds)
617 // +optional
618 NumberAvailable int32 `json:"numberAvailable,omitempty" protobuf:"varint,7,opt,name=numberAvailable"`
619
620 // The number of nodes that should be running the
621 // daemon pod and have none of the daemon pod running and available
622 // (ready for at least spec.minReadySeconds)
623 // +optional
624 NumberUnavailable int32 `json:"numberUnavailable,omitempty" protobuf:"varint,8,opt,name=numberUnavailable"`
625
626 // Count of hash collisions for the DaemonSet. The DaemonSet controller
627 // uses this field as a collision avoidance mechanism when it needs to
628 // create the name for the newest ControllerRevision.
629 // +optional
630 CollisionCount *int32 `json:"collisionCount,omitempty" protobuf:"varint,9,opt,name=collisionCount"`
631
632 // Represents the latest available observations of a DaemonSet's current state.
633 // +optional
634 // +patchMergeKey=type
635 // +patchStrategy=merge
636 Conditions []DaemonSetCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,10,rep,name=conditions"`
637}
638
639type DaemonSetConditionType string
640
641// TODO: Add valid condition types of a DaemonSet.
642
643// DaemonSetCondition describes the state of a DaemonSet at a certain point.
644type DaemonSetCondition struct {
645 // Type of DaemonSet condition.
646 Type DaemonSetConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=DaemonSetConditionType"`
647 // Status of the condition, one of True, False, Unknown.
648 Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"`
649 // Last time the condition transitioned from one status to another.
650 // +optional
651 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"`
652 // The reason for the condition's last transition.
653 // +optional
654 Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
655 // A human readable message indicating details about the transition.
656 // +optional
657 Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
658}
659
660// +genclient
661// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
662
663// DEPRECATED - This group version of DaemonSet is deprecated by apps/v1/DaemonSet. See the release notes for
664// more information.
665// DaemonSet represents the configuration of a daemon set.
666type DaemonSet struct {
667 metav1.TypeMeta `json:",inline"`
668 // Standard object's metadata.
669 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
670 // +optional
671 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
672
673 // The desired behavior of this daemon set.
674 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
675 // +optional
676 Spec DaemonSetSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
677
678 // The current status of this daemon set. This data may be
679 // out of date by some window of time.
680 // Populated by the system.
681 // Read-only.
682 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
683 // +optional
684 Status DaemonSetStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
685}
686
687const (
688 // DefaultDaemonSetUniqueLabelKey is the default label key that is added
689 // to existing DaemonSet pods to distinguish between old and new
690 // DaemonSet pods during DaemonSet template updates.
691 DefaultDaemonSetUniqueLabelKey = ControllerRevisionHashLabelKey
692)
693
694// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
695
696// DaemonSetList is a collection of daemon sets.
697type DaemonSetList struct {
698 metav1.TypeMeta `json:",inline"`
699 // Standard list metadata.
700 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
701 // +optional
702 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
703
704 // A list of daemon sets.
705 Items []DaemonSet `json:"items" protobuf:"bytes,2,rep,name=items"`
706}
707
708// +genclient
709// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
710
711// DEPRECATED - This group version of ReplicaSet is deprecated by apps/v1/ReplicaSet. See the release notes for
712// more information.
713// ReplicaSet ensures that a specified number of pod replicas are running at any given time.
714type ReplicaSet struct {
715 metav1.TypeMeta `json:",inline"`
716
717 // If the Labels of a ReplicaSet are empty, they are defaulted to
718 // be the same as the Pod(s) that the ReplicaSet manages.
719 // Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
720 // +optional
721 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
722
723 // Spec defines the specification of the desired behavior of the ReplicaSet.
724 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
725 // +optional
726 Spec ReplicaSetSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
727
728 // Status is the most recently observed status of the ReplicaSet.
729 // This data may be out of date by some window of time.
730 // Populated by the system.
731 // Read-only.
732 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
733 // +optional
734 Status ReplicaSetStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
735}
736
737// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
738
739// ReplicaSetList is a collection of ReplicaSets.
740type ReplicaSetList struct {
741 metav1.TypeMeta `json:",inline"`
742 // Standard list metadata.
743 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
744 // +optional
745 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
746
747 // List of ReplicaSets.
748 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller
749 Items []ReplicaSet `json:"items" protobuf:"bytes,2,rep,name=items"`
750}
751
752// ReplicaSetSpec is the specification of a ReplicaSet.
753type ReplicaSetSpec struct {
754 // Replicas is the number of desired replicas.
755 // This is a pointer to distinguish between explicit zero and unspecified.
756 // Defaults to 1.
757 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/#what-is-a-replicationcontroller
758 // +optional
759 Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
760
761 // Minimum number of seconds for which a newly created pod should be ready
762 // without any of its container crashing, for it to be considered available.
763 // Defaults to 0 (pod will be considered available as soon as it is ready)
764 // +optional
765 MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,4,opt,name=minReadySeconds"`
766
767 // Selector is a label query over pods that should match the replica count.
768 // Label keys and values that must match in order to be controlled by this replica set.
769 // It must match the pod template's labels.
770 // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
771 Selector *metav1.LabelSelector `json:"selector" protobuf:"bytes,2,opt,name=selector"`
772
773 // Template is the object that describes the pod that will be created if
774 // insufficient replicas are detected.
775 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template
776 // +optional
777 Template v1.PodTemplateSpec `json:"template,omitempty" protobuf:"bytes,3,opt,name=template"`
778}
779
780// ReplicaSetStatus represents the current status of a ReplicaSet.
781type ReplicaSetStatus struct {
782 // Replicas is the most recently oberved number of replicas.
783 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/#what-is-a-replicationcontroller
784 Replicas int32 `json:"replicas" protobuf:"varint,1,opt,name=replicas"`
785
786 // The number of pods that have labels matching the labels of the pod template of the replicaset.
787 // +optional
788 FullyLabeledReplicas int32 `json:"fullyLabeledReplicas,omitempty" protobuf:"varint,2,opt,name=fullyLabeledReplicas"`
789
790 // The number of ready replicas for this replica set.
791 // +optional
792 ReadyReplicas int32 `json:"readyReplicas,omitempty" protobuf:"varint,4,opt,name=readyReplicas"`
793
794 // The number of available replicas (ready for at least minReadySeconds) for this replica set.
795 // +optional
796 AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,5,opt,name=availableReplicas"`
797
798 // ObservedGeneration reflects the generation of the most recently observed ReplicaSet.
799 // +optional
800 ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,3,opt,name=observedGeneration"`
801
802 // Represents the latest available observations of a replica set's current state.
803 // +optional
804 // +patchMergeKey=type
805 // +patchStrategy=merge
806 Conditions []ReplicaSetCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,6,rep,name=conditions"`
807}
808
809type ReplicaSetConditionType string
810
811// These are valid conditions of a replica set.
812const (
813 // ReplicaSetReplicaFailure is added in a replica set when one of its pods fails to be created
814 // due to insufficient quota, limit ranges, pod security policy, node selectors, etc. or deleted
815 // due to kubelet being down or finalizers are failing.
816 ReplicaSetReplicaFailure ReplicaSetConditionType = "ReplicaFailure"
817)
818
819// ReplicaSetCondition describes the state of a replica set at a certain point.
820type ReplicaSetCondition struct {
821 // Type of replica set condition.
822 Type ReplicaSetConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=ReplicaSetConditionType"`
823 // Status of the condition, one of True, False, Unknown.
824 Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"`
825 // The last time the condition transitioned from one status to another.
826 // +optional
827 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"`
828 // The reason for the condition's last transition.
829 // +optional
830 Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
831 // A human readable message indicating details about the transition.
832 // +optional
833 Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
834}
835
836// +genclient
837// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
838
839// DEPRECATED - This group version of ControllerRevision is deprecated by apps/v1/ControllerRevision. See the
840// release notes for more information.
841// ControllerRevision implements an immutable snapshot of state data. Clients
842// are responsible for serializing and deserializing the objects that contain
843// their internal state.
844// Once a ControllerRevision has been successfully created, it can not be updated.
845// The API Server will fail validation of all requests that attempt to mutate
846// the Data field. ControllerRevisions may, however, be deleted. Note that, due to its use by both
847// the DaemonSet and StatefulSet controllers for update and rollback, this object is beta. However,
848// it may be subject to name and representation changes in future releases, and clients should not
849// depend on its stability. It is primarily for internal use by controllers.
850type ControllerRevision struct {
851 metav1.TypeMeta `json:",inline"`
852 // Standard object's metadata.
853 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
854 // +optional
855 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
856
857 // Data is the serialized representation of the state.
858 Data runtime.RawExtension `json:"data,omitempty" protobuf:"bytes,2,opt,name=data"`
859
860 // Revision indicates the revision of the state represented by Data.
861 Revision int64 `json:"revision" protobuf:"varint,3,opt,name=revision"`
862}
863
864// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
865
866// ControllerRevisionList is a resource containing a list of ControllerRevision objects.
867type ControllerRevisionList struct {
868 metav1.TypeMeta `json:",inline"`
869
870 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
871 // +optional
872 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
873
874 // Items is the list of ControllerRevisions
875 Items []ControllerRevision `json:"items" protobuf:"bytes,2,rep,name=items"`
876}