1 /* 2 Copyright 2016 The Kubernetes Authors. 3 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 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 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. 15 */ 16 17 package v1beta1 18 19 import ( 20 v1 "k8s.io/api/core/v1" 21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 "k8s.io/apimachinery/pkg/runtime" 23 "k8s.io/apimachinery/pkg/util/intstr" 24 ) 25 26 const ( 27 ControllerRevisionHashLabelKey = "controller-revision-hash" 28 StatefulSetRevisionLabel = ControllerRevisionHashLabelKey 29 StatefulSetPodNameLabel = "statefulset.kubernetes.io/pod-name" 30 ) 31 32 // ScaleSpec describes the attributes of a scale subresource 33 type ScaleSpec struct { 34 // replicas is the number of observed instances of the scaled object. 35 // +optional 36 Replicas int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"` 37 } 38 39 // ScaleStatus represents the current status of a scale subresource. 40 type ScaleStatus struct { 41 // replias is the actual number of observed instances of the scaled object. 42 Replicas int32 `json:"replicas" protobuf:"varint,1,opt,name=replicas"` 43 44 // selector is a label query over pods that should match the replicas count. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ 45 // +optional 46 Selector map[string]string `json:"selector,omitempty" protobuf:"bytes,2,rep,name=selector"` 47 48 // targetSelector is the label selector for pods that should match the replicas count. This is a serializated 49 // version of both map-based and more expressive set-based selectors. This is done to 50 // avoid introspection in the clients. The string will be in the same format as the 51 // query-param syntax. If the target type only supports map-based selectors, both this 52 // field and map-based selector field are populated. 53 // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors 54 // +optional 55 TargetSelector string `json:"targetSelector,omitempty" protobuf:"bytes,3,opt,name=targetSelector"` 56 } 57 58 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 59 // +k8s:prerelease-lifecycle-gen:introduced=1.6 60 // +k8s:prerelease-lifecycle-gen:deprecated=1.8 61 // +k8s:prerelease-lifecycle-gen:removed=1.16 62 // +k8s:prerelease-lifecycle-gen:replacement=autoscaling,v1,Scale 63 64 // Scale represents a scaling request for a resource. 65 type Scale struct { 66 metav1.TypeMeta `json:",inline"` 67 // Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata. 68 // +optional 69 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 70 71 // spec defines the behavior of the scale. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status. 72 // +optional 73 Spec ScaleSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` 74 75 // status defines current status of the scale. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status. Read-only. 76 // +optional 77 Status ScaleStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` 78 } 79 80 // +genclient 81 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 82 // +k8s:prerelease-lifecycle-gen:introduced=1.5 83 // +k8s:prerelease-lifecycle-gen:deprecated=1.8 84 // +k8s:prerelease-lifecycle-gen:removed=1.16 85 // +k8s:prerelease-lifecycle-gen:replacement=apps,v1,StatefulSet 86 87 // DEPRECATED - This group version of StatefulSet is deprecated by apps/v1beta2/StatefulSet. See the release notes for 88 // more information. 89 // StatefulSet represents a set of pods with consistent identities. 90 // Identities are defined as: 91 // - Network: A single stable DNS and hostname. 92 // - Storage: As many VolumeClaims as requested. 93 // 94 // The StatefulSet guarantees that a given network identity will always 95 // map to the same storage identity. 96 type StatefulSet struct { 97 metav1.TypeMeta `json:",inline"` 98 // +optional 99 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 100 101 // Spec defines the desired identities of pods in this set. 102 // +optional 103 Spec StatefulSetSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` 104 105 // Status is the current status of Pods in this StatefulSet. This data 106 // may be out of date by some window of time. 107 // +optional 108 Status StatefulSetStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` 109 } 110 111 // PodManagementPolicyType defines the policy for creating pods under a stateful set. 112 type PodManagementPolicyType string 113 114 const ( 115 // OrderedReadyPodManagement will create pods in strictly increasing order on 116 // scale up and strictly decreasing order on scale down, progressing only when 117 // the previous pod is ready or terminated. At most one pod will be changed 118 // at any time. 119 OrderedReadyPodManagement PodManagementPolicyType = "OrderedReady" 120 // ParallelPodManagement will create and delete pods as soon as the stateful set 121 // replica count is changed, and will not wait for pods to be ready or complete 122 // termination. 123 ParallelPodManagement PodManagementPolicyType = "Parallel" 124 ) 125 126 // StatefulSetUpdateStrategy indicates the strategy that the StatefulSet 127 // controller will use to perform updates. It includes any additional parameters 128 // necessary to perform the update for the indicated strategy. 129 type StatefulSetUpdateStrategy struct { 130 // Type indicates the type of the StatefulSetUpdateStrategy. 131 Type StatefulSetUpdateStrategyType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type,casttype=StatefulSetStrategyType"` 132 // RollingUpdate is used to communicate parameters when Type is RollingUpdateStatefulSetStrategyType. 133 RollingUpdate *RollingUpdateStatefulSetStrategy `json:"rollingUpdate,omitempty" protobuf:"bytes,2,opt,name=rollingUpdate"` 134 } 135 136 // StatefulSetUpdateStrategyType is a string enumeration type that enumerates 137 // all possible update strategies for the StatefulSet controller. 138 type StatefulSetUpdateStrategyType string 139 140 const ( 141 // RollingUpdateStatefulSetStrategyType indicates that update will be 142 // applied to all Pods in the StatefulSet with respect to the StatefulSet 143 // ordering constraints. When a scale operation is performed with this 144 // strategy, new Pods will be created from the specification version indicated 145 // by the StatefulSet's updateRevision. 146 RollingUpdateStatefulSetStrategyType StatefulSetUpdateStrategyType = "RollingUpdate" 147 // OnDeleteStatefulSetStrategyType triggers the legacy behavior. Version 148 // tracking and ordered rolling restarts are disabled. Pods are recreated 149 // from the StatefulSetSpec when they are manually deleted. When a scale 150 // operation is performed with this strategy,specification version indicated 151 // by the StatefulSet's currentRevision. 152 OnDeleteStatefulSetStrategyType StatefulSetUpdateStrategyType = "OnDelete" 153 ) 154 155 // RollingUpdateStatefulSetStrategy is used to communicate parameter for RollingUpdateStatefulSetStrategyType. 156 type RollingUpdateStatefulSetStrategy struct { 157 // Partition indicates the ordinal at which the StatefulSet should be partitioned 158 // for updates. During a rolling update, all pods from ordinal Replicas-1 to 159 // Partition are updated. All pods from ordinal Partition-1 to 0 remain untouched. 160 // This is helpful in being able to do a canary based deployment. The default value is 0. 161 Partition *int32 `json:"partition,omitempty" protobuf:"varint,1,opt,name=partition"` 162 // maxUnavailable is the maximum number of pods that can be unavailable during the update. 163 // Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). 164 // Absolute number is calculated from percentage by rounding up. This can not be 0. 165 // Defaults to 1. This field is alpha-level and is only honored by servers that enable the 166 // MaxUnavailableStatefulSet feature. The field applies to all pods in the range 0 to 167 // Replicas-1. That means if there is any unavailable pod in the range 0 to Replicas-1, it 168 // will be counted towards MaxUnavailable. 169 // +optional 170 MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty" protobuf:"varint,2,opt,name=maxUnavailable"` 171 } 172 173 // PersistentVolumeClaimRetentionPolicyType is a string enumeration of the policies that will determine 174 // when volumes from the VolumeClaimTemplates will be deleted when the controlling StatefulSet is 175 // deleted or scaled down. 176 type PersistentVolumeClaimRetentionPolicyType string 177 178 const ( 179 // RetainPersistentVolumeClaimRetentionPolicyType is the default 180 // PersistentVolumeClaimRetentionPolicy and specifies that 181 // PersistentVolumeClaims associated with StatefulSet VolumeClaimTemplates 182 // will not be deleted. 183 RetainPersistentVolumeClaimRetentionPolicyType PersistentVolumeClaimRetentionPolicyType = "Retain" 184 // RetentionPersistentVolumeClaimRetentionPolicyType specifies that 185 // PersistentVolumeClaims associated with StatefulSet VolumeClaimTemplates 186 // will be deleted in the scenario specified in 187 // StatefulSetPersistentVolumeClaimRetentionPolicy. 188 RetentionPersistentVolumeClaimRetentionPolicyType PersistentVolumeClaimRetentionPolicyType = "Delete" 189 ) 190 191 // StatefulSetPersistentVolumeClaimRetentionPolicy describes the policy used for PVCs 192 // created from the StatefulSet VolumeClaimTemplates. 193 type StatefulSetPersistentVolumeClaimRetentionPolicy struct { 194 // whenDeleted specifies what happens to PVCs created from StatefulSet 195 // VolumeClaimTemplates when the StatefulSet is deleted. The default policy 196 // of `Retain` causes PVCs to not be affected by StatefulSet deletion. The 197 // `Delete` policy causes those PVCs to be deleted. 198 WhenDeleted PersistentVolumeClaimRetentionPolicyType `json:"whenDeleted,omitempty" protobuf:"bytes,1,opt,name=whenDeleted,casttype=PersistentVolumeClaimRetentionPolicyType"` 199 // whenScaled specifies what happens to PVCs created from StatefulSet 200 // VolumeClaimTemplates when the StatefulSet is scaled down. The default 201 // policy of `Retain` causes PVCs to not be affected by a scaledown. The 202 // `Delete` policy causes the associated PVCs for any excess pods above 203 // the replica count to be deleted. 204 WhenScaled PersistentVolumeClaimRetentionPolicyType `json:"whenScaled,omitempty" protobuf:"bytes,2,opt,name=whenScaled,casttype=PersistentVolumeClaimRetentionPolicyType"` 205 } 206 207 // StatefulSetOrdinals describes the policy used for replica ordinal assignment 208 // in this StatefulSet. 209 type StatefulSetOrdinals struct { 210 // start is the number representing the first replica's index. It may be used 211 // to number replicas from an alternate index (eg: 1-indexed) over the default 212 // 0-indexed names, or to orchestrate progressive movement of replicas from 213 // one StatefulSet to another. 214 // If set, replica indices will be in the range: 215 // [.spec.ordinals.start, .spec.ordinals.start + .spec.replicas). 216 // If unset, defaults to 0. Replica indices will be in the range: 217 // [0, .spec.replicas). 218 // +optional 219 Start int32 `json:"start" protobuf:"varint,1,opt,name=start"` 220 } 221 222 // A StatefulSetSpec is the specification of a StatefulSet. 223 type StatefulSetSpec struct { 224 // replicas is the desired number of replicas of the given Template. 225 // These are replicas in the sense that they are instantiations of the 226 // same Template, but individual replicas also have a consistent identity. 227 // If unspecified, defaults to 1. 228 // TODO: Consider a rename of this field. 229 // +optional 230 Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"` 231 232 // selector is a label query over pods that should match the replica count. 233 // If empty, defaulted to labels on the pod template. 234 // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors 235 // +optional 236 Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,2,opt,name=selector"` 237 238 // template is the object that describes the pod that will be created if 239 // insufficient replicas are detected. Each pod stamped out by the StatefulSet 240 // will fulfill this Template, but have a unique identity from the rest 241 // of the StatefulSet. Each pod will be named with the format 242 // <statefulsetname>-<podindex>. For example, a pod in a StatefulSet named 243 // "web" with index number "3" would be named "web-3". 244 Template v1.PodTemplateSpec `json:"template" protobuf:"bytes,3,opt,name=template"` 245 246 // volumeClaimTemplates is a list of claims that pods are allowed to reference. 247 // The StatefulSet controller is responsible for mapping network identities to 248 // claims in a way that maintains the identity of a pod. Every claim in 249 // this list must have at least one matching (by name) volumeMount in one 250 // container in the template. A claim in this list takes precedence over 251 // any volumes in the template, with the same name. 252 // TODO: Define the behavior if a claim already exists with the same name. 253 // +optional 254 // +listType=atomic 255 VolumeClaimTemplates []v1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty" protobuf:"bytes,4,rep,name=volumeClaimTemplates"` 256 257 // serviceName is the name of the service that governs this StatefulSet. 258 // This service must exist before the StatefulSet, and is responsible for 259 // the network identity of the set. Pods get DNS/hostnames that follow the 260 // pattern: pod-specific-string.serviceName.default.svc.cluster.local 261 // where "pod-specific-string" is managed by the StatefulSet controller. 262 ServiceName string `json:"serviceName" protobuf:"bytes,5,opt,name=serviceName"` 263 264 // podManagementPolicy controls how pods are created during initial scale up, 265 // when replacing pods on nodes, or when scaling down. The default policy is 266 // `OrderedReady`, where pods are created in increasing order (pod-0, then 267 // pod-1, etc) and the controller will wait until each pod is ready before 268 // continuing. When scaling down, the pods are removed in the opposite order. 269 // The alternative policy is `Parallel` which will create pods in parallel 270 // to match the desired scale without waiting, and on scale down will delete 271 // all pods at once. 272 // +optional 273 PodManagementPolicy PodManagementPolicyType `json:"podManagementPolicy,omitempty" protobuf:"bytes,6,opt,name=podManagementPolicy,casttype=PodManagementPolicyType"` 274 275 // updateStrategy indicates the StatefulSetUpdateStrategy that will be 276 // employed to update Pods in the StatefulSet when a revision is made to 277 // Template. 278 UpdateStrategy StatefulSetUpdateStrategy `json:"updateStrategy,omitempty" protobuf:"bytes,7,opt,name=updateStrategy"` 279 280 // revisionHistoryLimit is the maximum number of revisions that will 281 // be maintained in the StatefulSet's revision history. The revision history 282 // consists of all revisions not represented by a currently applied 283 // StatefulSetSpec version. The default value is 10. 284 RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,8,opt,name=revisionHistoryLimit"` 285 286 // minReadySeconds is the minimum number of seconds for which a newly created pod should be ready 287 // without any of its container crashing for it to be considered available. 288 // Defaults to 0 (pod will be considered available as soon as it is ready) 289 // +optional 290 MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,9,opt,name=minReadySeconds"` 291 292 // PersistentVolumeClaimRetentionPolicy describes the policy used for PVCs created from 293 // the StatefulSet VolumeClaimTemplates. This requires the 294 // StatefulSetAutoDeletePVC feature gate to be enabled, which is alpha. 295 // +optional 296 PersistentVolumeClaimRetentionPolicy *StatefulSetPersistentVolumeClaimRetentionPolicy `json:"persistentVolumeClaimRetentionPolicy,omitempty" protobuf:"bytes,10,opt,name=persistentVolumeClaimRetentionPolicy"` 297 298 // ordinals controls the numbering of replica indices in a StatefulSet. The 299 // default ordinals behavior assigns a "0" index to the first replica and 300 // increments the index by one for each additional replica requested. Using 301 // the ordinals field requires the StatefulSetStartOrdinal feature gate to be 302 // enabled, which is beta. 303 // +optional 304 Ordinals *StatefulSetOrdinals `json:"ordinals,omitempty" protobuf:"bytes,11,opt,name=ordinals"` 305 } 306 307 // StatefulSetStatus represents the current state of a StatefulSet. 308 type StatefulSetStatus struct { 309 // observedGeneration is the most recent generation observed for this StatefulSet. It corresponds to the 310 // StatefulSet's generation, which is updated on mutation by the API Server. 311 // +optional 312 ObservedGeneration *int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"` 313 314 // replicas is the number of Pods created by the StatefulSet controller. 315 Replicas int32 `json:"replicas" protobuf:"varint,2,opt,name=replicas"` 316 317 // readyReplicas is the number of pods created by this StatefulSet controller with a Ready Condition. 318 ReadyReplicas int32 `json:"readyReplicas,omitempty" protobuf:"varint,3,opt,name=readyReplicas"` 319 320 // currentReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version 321 // indicated by currentRevision. 322 CurrentReplicas int32 `json:"currentReplicas,omitempty" protobuf:"varint,4,opt,name=currentReplicas"` 323 324 // updatedReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version 325 // indicated by updateRevision. 326 UpdatedReplicas int32 `json:"updatedReplicas,omitempty" protobuf:"varint,5,opt,name=updatedReplicas"` 327 328 // currentRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the 329 // sequence [0,currentReplicas). 330 CurrentRevision string `json:"currentRevision,omitempty" protobuf:"bytes,6,opt,name=currentRevision"` 331 332 // updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence 333 // [replicas-updatedReplicas,replicas) 334 UpdateRevision string `json:"updateRevision,omitempty" protobuf:"bytes,7,opt,name=updateRevision"` 335 336 // collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller 337 // uses this field as a collision avoidance mechanism when it needs to create the name for the 338 // newest ControllerRevision. 339 // +optional 340 CollisionCount *int32 `json:"collisionCount,omitempty" protobuf:"varint,9,opt,name=collisionCount"` 341 342 // conditions represent the latest available observations of a statefulset's current state. 343 // +optional 344 // +patchMergeKey=type 345 // +patchStrategy=merge 346 // +listType=map 347 // +listMapKey=type 348 Conditions []StatefulSetCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,10,rep,name=conditions"` 349 350 // availableReplicas is the total number of available pods (ready for at least minReadySeconds) targeted by this StatefulSet. 351 // +optional 352 AvailableReplicas int32 `json:"availableReplicas" protobuf:"varint,11,opt,name=availableReplicas"` 353 } 354 355 type StatefulSetConditionType string 356 357 // StatefulSetCondition describes the state of a statefulset at a certain point. 358 type StatefulSetCondition struct { 359 // Type of statefulset condition. 360 Type StatefulSetConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=StatefulSetConditionType"` 361 // Status of the condition, one of True, False, Unknown. 362 Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"` 363 // Last time the condition transitioned from one status to another. 364 // +optional 365 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"` 366 // The reason for the condition's last transition. 367 // +optional 368 Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"` 369 // A human readable message indicating details about the transition. 370 // +optional 371 Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"` 372 } 373 374 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 375 // +k8s:prerelease-lifecycle-gen:introduced=1.5 376 // +k8s:prerelease-lifecycle-gen:deprecated=1.8 377 // +k8s:prerelease-lifecycle-gen:removed=1.16 378 // +k8s:prerelease-lifecycle-gen:replacement=apps,v1,StatefulSetList 379 380 // StatefulSetList is a collection of StatefulSets. 381 type StatefulSetList struct { 382 metav1.TypeMeta `json:",inline"` 383 // +optional 384 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 385 Items []StatefulSet `json:"items" protobuf:"bytes,2,rep,name=items"` 386 } 387 388 // +genclient 389 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 390 // +k8s:prerelease-lifecycle-gen:introduced=1.6 391 // +k8s:prerelease-lifecycle-gen:deprecated=1.8 392 // +k8s:prerelease-lifecycle-gen:removed=1.16 393 // +k8s:prerelease-lifecycle-gen:replacement=apps,v1,Deployment 394 395 // DEPRECATED - This group version of Deployment is deprecated by apps/v1beta2/Deployment. See the release notes for 396 // more information. 397 // Deployment enables declarative updates for Pods and ReplicaSets. 398 type Deployment struct { 399 metav1.TypeMeta `json:",inline"` 400 // Standard object metadata. 401 // +optional 402 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 403 404 // Specification of the desired behavior of the Deployment. 405 // +optional 406 Spec DeploymentSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` 407 408 // Most recently observed status of the Deployment. 409 // +optional 410 Status DeploymentStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` 411 } 412 413 // DeploymentSpec is the specification of the desired behavior of the Deployment. 414 type DeploymentSpec struct { 415 // replicas is the number of desired pods. This is a pointer to distinguish between explicit 416 // zero and not specified. Defaults to 1. 417 // +optional 418 Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"` 419 420 // selector is the label selector for pods. Existing ReplicaSets whose pods are 421 // selected by this will be the ones affected by this deployment. 422 // +optional 423 Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,2,opt,name=selector"` 424 425 // Template describes the pods that will be created. 426 // The only allowed template.spec.restartPolicy value is "Always". 427 Template v1.PodTemplateSpec `json:"template" protobuf:"bytes,3,opt,name=template"` 428 429 // The deployment strategy to use to replace existing pods with new ones. 430 // +optional 431 // +patchStrategy=retainKeys 432 Strategy DeploymentStrategy `json:"strategy,omitempty" patchStrategy:"retainKeys" protobuf:"bytes,4,opt,name=strategy"` 433 434 // minReadySeconds is the minimum number of seconds for which a newly created pod should be ready 435 // without any of its container crashing, for it to be considered available. 436 // Defaults to 0 (pod will be considered available as soon as it is ready) 437 // +optional 438 MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,5,opt,name=minReadySeconds"` 439 440 // revisionHistoryLimit is the number of old ReplicaSets to retain to allow rollback. 441 // This is a pointer to distinguish between explicit zero and not specified. 442 // Defaults to 2. 443 // +optional 444 RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,6,opt,name=revisionHistoryLimit"` 445 446 // paused indicates that the deployment is paused. 447 // +optional 448 Paused bool `json:"paused,omitempty" protobuf:"varint,7,opt,name=paused"` 449 450 // DEPRECATED. 451 // rollbackTo is the config this deployment is rolling back to. Will be cleared after rollback is done. 452 // +optional 453 RollbackTo *RollbackConfig `json:"rollbackTo,omitempty" protobuf:"bytes,8,opt,name=rollbackTo"` 454 455 // progressDeadlineSeconds is the maximum time in seconds for a deployment to make progress before it 456 // is considered to be failed. The deployment controller will continue to 457 // process failed deployments and a condition with a ProgressDeadlineExceeded 458 // reason will be surfaced in the deployment status. Note that progress will 459 // not be estimated during the time a deployment is paused. Defaults to 600s. 460 // +optional 461 ProgressDeadlineSeconds *int32 `json:"progressDeadlineSeconds,omitempty" protobuf:"varint,9,opt,name=progressDeadlineSeconds"` 462 } 463 464 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 465 // +k8s:prerelease-lifecycle-gen:introduced=1.6 466 // +k8s:prerelease-lifecycle-gen:deprecated=1.8 467 // +k8s:prerelease-lifecycle-gen:removed=1.16 468 // +k8s:prerelease-lifecycle-gen:replacement=apps,v1,DeploymentRollback 469 470 // DEPRECATED. 471 // DeploymentRollback stores the information required to rollback a deployment. 472 type DeploymentRollback struct { 473 metav1.TypeMeta `json:",inline"` 474 // Required: This must match the Name of a deployment. 475 Name string `json:"name" protobuf:"bytes,1,opt,name=name"` 476 // The annotations to be updated to a deployment 477 // +optional 478 UpdatedAnnotations map[string]string `json:"updatedAnnotations,omitempty" protobuf:"bytes,2,rep,name=updatedAnnotations"` 479 // The config of this deployment rollback. 480 RollbackTo RollbackConfig `json:"rollbackTo" protobuf:"bytes,3,opt,name=rollbackTo"` 481 } 482 483 // DEPRECATED. 484 type RollbackConfig struct { 485 // The revision to rollback to. If set to 0, rollback to the last revision. 486 // +optional 487 Revision int64 `json:"revision,omitempty" protobuf:"varint,1,opt,name=revision"` 488 } 489 490 const ( 491 // DefaultDeploymentUniqueLabelKey is the default key of the selector that is added 492 // to existing ReplicaSets (and label key that is added to its pods) to prevent the existing ReplicaSets 493 // to select new pods (and old pods being select by new ReplicaSet). 494 DefaultDeploymentUniqueLabelKey string = "pod-template-hash" 495 ) 496 497 // DeploymentStrategy describes how to replace existing pods with new ones. 498 type DeploymentStrategy struct { 499 // Type of deployment. Can be "Recreate" or "RollingUpdate". Default is RollingUpdate. 500 // +optional 501 Type DeploymentStrategyType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type,casttype=DeploymentStrategyType"` 502 503 // Rolling update config params. Present only if DeploymentStrategyType = 504 // RollingUpdate. 505 //--- 506 // TODO: Update this to follow our convention for oneOf, whatever we decide it 507 // to be. 508 // +optional 509 RollingUpdate *RollingUpdateDeployment `json:"rollingUpdate,omitempty" protobuf:"bytes,2,opt,name=rollingUpdate"` 510 } 511 512 type DeploymentStrategyType string 513 514 const ( 515 // Kill all existing pods before creating new ones. 516 RecreateDeploymentStrategyType DeploymentStrategyType = "Recreate" 517 518 // Replace the old ReplicaSets by new one using rolling update i.e gradually scale down the old ReplicaSets and scale up the new one. 519 RollingUpdateDeploymentStrategyType DeploymentStrategyType = "RollingUpdate" 520 ) 521 522 // Spec to control the desired behavior of rolling update. 523 type RollingUpdateDeployment struct { 524 // The maximum number of pods that can be unavailable during the update. 525 // Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). 526 // Absolute number is calculated from percentage by rounding down. 527 // This can not be 0 if MaxSurge is 0. 528 // Defaults to 25%. 529 // Example: when this is set to 30%, the old ReplicaSet can be scaled down to 70% of desired pods 530 // immediately when the rolling update starts. Once new pods are ready, old ReplicaSet 531 // can be scaled down further, followed by scaling up the new ReplicaSet, ensuring 532 // that the total number of pods available at all times during the update is at 533 // least 70% of desired pods. 534 // +optional 535 MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty" protobuf:"bytes,1,opt,name=maxUnavailable"` 536 537 // The maximum number of pods that can be scheduled above the desired number of 538 // pods. 539 // Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). 540 // This can not be 0 if MaxUnavailable is 0. 541 // Absolute number is calculated from percentage by rounding up. 542 // Defaults to 25%. 543 // Example: when this is set to 30%, the new ReplicaSet can be scaled up immediately when 544 // the rolling update starts, such that the total number of old and new pods do not exceed 545 // 130% of desired pods. Once old pods have been killed, 546 // new ReplicaSet can be scaled up further, ensuring that total number of pods running 547 // at any time during the update is at most 130% of desired pods. 548 // +optional 549 MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty" protobuf:"bytes,2,opt,name=maxSurge"` 550 } 551 552 // DeploymentStatus is the most recently observed status of the Deployment. 553 type DeploymentStatus struct { 554 // observedGeneration is the generation observed by the deployment controller. 555 // +optional 556 ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"` 557 558 // replicas is the total number of non-terminated pods targeted by this deployment (their labels match the selector). 559 // +optional 560 Replicas int32 `json:"replicas,omitempty" protobuf:"varint,2,opt,name=replicas"` 561 562 // updatedReplicas is the total number of non-terminated pods targeted by this deployment that have the desired template spec. 563 // +optional 564 UpdatedReplicas int32 `json:"updatedReplicas,omitempty" protobuf:"varint,3,opt,name=updatedReplicas"` 565 566 // readyReplicas is the number of pods targeted by this Deployment controller with a Ready Condition. 567 // +optional 568 ReadyReplicas int32 `json:"readyReplicas,omitempty" protobuf:"varint,7,opt,name=readyReplicas"` 569 570 // Total number of available pods (ready for at least minReadySeconds) targeted by this deployment. 571 // +optional 572 AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,4,opt,name=availableReplicas"` 573 574 // unavailableReplicas is the total number of unavailable pods targeted by this deployment. This is the total number of 575 // pods that are still required for the deployment to have 100% available capacity. They may 576 // either be pods that are running but not yet available or pods that still have not been created. 577 // +optional 578 UnavailableReplicas int32 `json:"unavailableReplicas,omitempty" protobuf:"varint,5,opt,name=unavailableReplicas"` 579 580 // Conditions represent the latest available observations of a deployment's current state. 581 // +patchMergeKey=type 582 // +patchStrategy=merge 583 // +listType=map 584 // +listMapKey=type 585 Conditions []DeploymentCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,6,rep,name=conditions"` 586 587 // collisionCount is the count of hash collisions for the Deployment. The Deployment controller uses this 588 // field as a collision avoidance mechanism when it needs to create the name for the 589 // newest ReplicaSet. 590 // +optional 591 CollisionCount *int32 `json:"collisionCount,omitempty" protobuf:"varint,8,opt,name=collisionCount"` 592 } 593 594 type DeploymentConditionType string 595 596 // These are valid conditions of a deployment. 597 const ( 598 // Available means the deployment is available, ie. at least the minimum available 599 // replicas required are up and running for at least minReadySeconds. 600 DeploymentAvailable DeploymentConditionType = "Available" 601 // Progressing means the deployment is progressing. Progress for a deployment is 602 // considered when a new replica set is created or adopted, and when new pods scale 603 // up or old pods scale down. Progress is not estimated for paused deployments or 604 // when progressDeadlineSeconds is not specified. 605 DeploymentProgressing DeploymentConditionType = "Progressing" 606 // ReplicaFailure is added in a deployment when one of its pods fails to be created 607 // or deleted. 608 DeploymentReplicaFailure DeploymentConditionType = "ReplicaFailure" 609 ) 610 611 // DeploymentCondition describes the state of a deployment at a certain point. 612 type DeploymentCondition struct { 613 // Type of deployment condition. 614 Type DeploymentConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=DeploymentConditionType"` 615 // Status of the condition, one of True, False, Unknown. 616 Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"` 617 // The last time this condition was updated. 618 LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty" protobuf:"bytes,6,opt,name=lastUpdateTime"` 619 // Last time the condition transitioned from one status to another. 620 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,7,opt,name=lastTransitionTime"` 621 // The reason for the condition's last transition. 622 Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"` 623 // A human readable message indicating details about the transition. 624 Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"` 625 } 626 627 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 628 // +k8s:prerelease-lifecycle-gen:introduced=1.6 629 // +k8s:prerelease-lifecycle-gen:deprecated=1.8 630 // +k8s:prerelease-lifecycle-gen:removed=1.16 631 // +k8s:prerelease-lifecycle-gen:replacement=apps,v1,DeploymentList 632 633 // DeploymentList is a list of Deployments. 634 type DeploymentList struct { 635 metav1.TypeMeta `json:",inline"` 636 // Standard list metadata. 637 // +optional 638 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 639 640 // Items is the list of Deployments. 641 Items []Deployment `json:"items" protobuf:"bytes,2,rep,name=items"` 642 } 643 644 // +genclient 645 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 646 // +k8s:prerelease-lifecycle-gen:introduced=1.7 647 // +k8s:prerelease-lifecycle-gen:deprecated=1.8 648 // +k8s:prerelease-lifecycle-gen:removed=1.16 649 // +k8s:prerelease-lifecycle-gen:replacement=apps,v1,ControllerRevision 650 651 // DEPRECATED - This group version of ControllerRevision is deprecated by apps/v1beta2/ControllerRevision. See the 652 // release notes for more information. 653 // ControllerRevision implements an immutable snapshot of state data. Clients 654 // are responsible for serializing and deserializing the objects that contain 655 // their internal state. 656 // Once a ControllerRevision has been successfully created, it can not be updated. 657 // The API Server will fail validation of all requests that attempt to mutate 658 // the Data field. ControllerRevisions may, however, be deleted. Note that, due to its use by both 659 // the DaemonSet and StatefulSet controllers for update and rollback, this object is beta. However, 660 // it may be subject to name and representation changes in future releases, and clients should not 661 // depend on its stability. It is primarily for internal use by controllers. 662 type ControllerRevision struct { 663 metav1.TypeMeta `json:",inline"` 664 // Standard object's metadata. 665 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 666 // +optional 667 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 668 669 // data is the serialized representation of the state. 670 Data runtime.RawExtension `json:"data,omitempty" protobuf:"bytes,2,opt,name=data"` 671 672 // revision indicates the revision of the state represented by Data. 673 Revision int64 `json:"revision" protobuf:"varint,3,opt,name=revision"` 674 } 675 676 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 677 // +k8s:prerelease-lifecycle-gen:introduced=1.7 678 // +k8s:prerelease-lifecycle-gen:deprecated=1.8 679 // +k8s:prerelease-lifecycle-gen:removed=1.16 680 // +k8s:prerelease-lifecycle-gen:replacement=apps,v1,ControllerRevisionList 681 682 // ControllerRevisionList is a resource containing a list of ControllerRevision objects. 683 type ControllerRevisionList struct { 684 metav1.TypeMeta `json:",inline"` 685 686 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 687 // +optional 688 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 689 690 // Items is the list of ControllerRevisions 691 Items []ControllerRevision `json:"items" protobuf:"bytes,2,rep,name=items"` 692 } 693