Zack Williams | e940c7a | 2019-08-21 14:25:39 -0700 | [diff] [blame] | 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 | // desired number of instances for 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 | // actual number of observed instances of the scaled object. |
| 42 | Replicas int32 `json:"replicas" protobuf:"varint,1,opt,name=replicas"` |
| 43 | |
| 44 | // label query over pods that should match the replicas count. More info: http://kubernetes.io/docs/user-guide/labels#label-selectors |
| 45 | // +optional |
| 46 | Selector map[string]string `json:"selector,omitempty" protobuf:"bytes,2,rep,name=selector"` |
| 47 | |
| 48 | // 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 | |
| 60 | // Scale represents a scaling request for a resource. |
| 61 | type Scale struct { |
| 62 | metav1.TypeMeta `json:",inline"` |
| 63 | // Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata. |
| 64 | // +optional |
| 65 | metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 66 | |
| 67 | // defines the behavior of the scale. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status. |
| 68 | // +optional |
| 69 | Spec ScaleSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` |
| 70 | |
| 71 | // current status of the scale. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status. Read-only. |
| 72 | // +optional |
| 73 | Status ScaleStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` |
| 74 | } |
| 75 | |
| 76 | // +genclient |
| 77 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 78 | |
| 79 | // DEPRECATED - This group version of StatefulSet is deprecated by apps/v1beta2/StatefulSet. See the release notes for |
| 80 | // more information. |
| 81 | // StatefulSet represents a set of pods with consistent identities. |
| 82 | // Identities are defined as: |
| 83 | // - Network: A single stable DNS and hostname. |
| 84 | // - Storage: As many VolumeClaims as requested. |
| 85 | // The StatefulSet guarantees that a given network identity will always |
| 86 | // map to the same storage identity. |
| 87 | type StatefulSet struct { |
| 88 | metav1.TypeMeta `json:",inline"` |
| 89 | // +optional |
| 90 | metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 91 | |
| 92 | // Spec defines the desired identities of pods in this set. |
| 93 | // +optional |
| 94 | Spec StatefulSetSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` |
| 95 | |
| 96 | // Status is the current status of Pods in this StatefulSet. This data |
| 97 | // may be out of date by some window of time. |
| 98 | // +optional |
| 99 | Status StatefulSetStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` |
| 100 | } |
| 101 | |
| 102 | // PodManagementPolicyType defines the policy for creating pods under a stateful set. |
| 103 | type PodManagementPolicyType string |
| 104 | |
| 105 | const ( |
| 106 | // OrderedReadyPodManagement will create pods in strictly increasing order on |
| 107 | // scale up and strictly decreasing order on scale down, progressing only when |
| 108 | // the previous pod is ready or terminated. At most one pod will be changed |
| 109 | // at any time. |
| 110 | OrderedReadyPodManagement PodManagementPolicyType = "OrderedReady" |
| 111 | // ParallelPodManagement will create and delete pods as soon as the stateful set |
| 112 | // replica count is changed, and will not wait for pods to be ready or complete |
| 113 | // termination. |
| 114 | ParallelPodManagement PodManagementPolicyType = "Parallel" |
| 115 | ) |
| 116 | |
| 117 | // StatefulSetUpdateStrategy indicates the strategy that the StatefulSet |
| 118 | // controller will use to perform updates. It includes any additional parameters |
| 119 | // necessary to perform the update for the indicated strategy. |
| 120 | type StatefulSetUpdateStrategy struct { |
| 121 | // Type indicates the type of the StatefulSetUpdateStrategy. |
| 122 | Type StatefulSetUpdateStrategyType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type,casttype=StatefulSetStrategyType"` |
| 123 | // RollingUpdate is used to communicate parameters when Type is RollingUpdateStatefulSetStrategyType. |
| 124 | RollingUpdate *RollingUpdateStatefulSetStrategy `json:"rollingUpdate,omitempty" protobuf:"bytes,2,opt,name=rollingUpdate"` |
| 125 | } |
| 126 | |
| 127 | // StatefulSetUpdateStrategyType is a string enumeration type that enumerates |
| 128 | // all possible update strategies for the StatefulSet controller. |
| 129 | type StatefulSetUpdateStrategyType string |
| 130 | |
| 131 | const ( |
| 132 | // RollingUpdateStatefulSetStrategyType indicates that update will be |
| 133 | // applied to all Pods in the StatefulSet with respect to the StatefulSet |
| 134 | // ordering constraints. When a scale operation is performed with this |
| 135 | // strategy, new Pods will be created from the specification version indicated |
| 136 | // by the StatefulSet's updateRevision. |
| 137 | RollingUpdateStatefulSetStrategyType = "RollingUpdate" |
| 138 | // OnDeleteStatefulSetStrategyType triggers the legacy behavior. Version |
| 139 | // tracking and ordered rolling restarts are disabled. Pods are recreated |
| 140 | // from the StatefulSetSpec when they are manually deleted. When a scale |
| 141 | // operation is performed with this strategy,specification version indicated |
| 142 | // by the StatefulSet's currentRevision. |
| 143 | OnDeleteStatefulSetStrategyType = "OnDelete" |
| 144 | ) |
| 145 | |
| 146 | // RollingUpdateStatefulSetStrategy is used to communicate parameter for RollingUpdateStatefulSetStrategyType. |
| 147 | type RollingUpdateStatefulSetStrategy struct { |
| 148 | // Partition indicates the ordinal at which the StatefulSet should be |
| 149 | // partitioned. |
| 150 | Partition *int32 `json:"partition,omitempty" protobuf:"varint,1,opt,name=partition"` |
| 151 | } |
| 152 | |
| 153 | // A StatefulSetSpec is the specification of a StatefulSet. |
| 154 | type StatefulSetSpec struct { |
| 155 | // replicas is the desired number of replicas of the given Template. |
| 156 | // These are replicas in the sense that they are instantiations of the |
| 157 | // same Template, but individual replicas also have a consistent identity. |
| 158 | // If unspecified, defaults to 1. |
| 159 | // TODO: Consider a rename of this field. |
| 160 | // +optional |
| 161 | Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"` |
| 162 | |
| 163 | // selector is a label query over pods that should match the replica count. |
| 164 | // If empty, defaulted to labels on the pod template. |
| 165 | // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors |
| 166 | // +optional |
| 167 | Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,2,opt,name=selector"` |
| 168 | |
| 169 | // template is the object that describes the pod that will be created if |
| 170 | // insufficient replicas are detected. Each pod stamped out by the StatefulSet |
| 171 | // will fulfill this Template, but have a unique identity from the rest |
| 172 | // of the StatefulSet. |
| 173 | Template v1.PodTemplateSpec `json:"template" protobuf:"bytes,3,opt,name=template"` |
| 174 | |
| 175 | // volumeClaimTemplates is a list of claims that pods are allowed to reference. |
| 176 | // The StatefulSet controller is responsible for mapping network identities to |
| 177 | // claims in a way that maintains the identity of a pod. Every claim in |
| 178 | // this list must have at least one matching (by name) volumeMount in one |
| 179 | // container in the template. A claim in this list takes precedence over |
| 180 | // any volumes in the template, with the same name. |
| 181 | // TODO: Define the behavior if a claim already exists with the same name. |
| 182 | // +optional |
| 183 | VolumeClaimTemplates []v1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty" protobuf:"bytes,4,rep,name=volumeClaimTemplates"` |
| 184 | |
| 185 | // serviceName is the name of the service that governs this StatefulSet. |
| 186 | // This service must exist before the StatefulSet, and is responsible for |
| 187 | // the network identity of the set. Pods get DNS/hostnames that follow the |
| 188 | // pattern: pod-specific-string.serviceName.default.svc.cluster.local |
| 189 | // where "pod-specific-string" is managed by the StatefulSet controller. |
| 190 | ServiceName string `json:"serviceName" protobuf:"bytes,5,opt,name=serviceName"` |
| 191 | |
| 192 | // podManagementPolicy controls how pods are created during initial scale up, |
| 193 | // when replacing pods on nodes, or when scaling down. The default policy is |
| 194 | // `OrderedReady`, where pods are created in increasing order (pod-0, then |
| 195 | // pod-1, etc) and the controller will wait until each pod is ready before |
| 196 | // continuing. When scaling down, the pods are removed in the opposite order. |
| 197 | // The alternative policy is `Parallel` which will create pods in parallel |
| 198 | // to match the desired scale without waiting, and on scale down will delete |
| 199 | // all pods at once. |
| 200 | // +optional |
| 201 | PodManagementPolicy PodManagementPolicyType `json:"podManagementPolicy,omitempty" protobuf:"bytes,6,opt,name=podManagementPolicy,casttype=PodManagementPolicyType"` |
| 202 | |
| 203 | // updateStrategy indicates the StatefulSetUpdateStrategy that will be |
| 204 | // employed to update Pods in the StatefulSet when a revision is made to |
| 205 | // Template. |
| 206 | UpdateStrategy StatefulSetUpdateStrategy `json:"updateStrategy,omitempty" protobuf:"bytes,7,opt,name=updateStrategy"` |
| 207 | |
| 208 | // revisionHistoryLimit is the maximum number of revisions that will |
| 209 | // be maintained in the StatefulSet's revision history. The revision history |
| 210 | // consists of all revisions not represented by a currently applied |
| 211 | // StatefulSetSpec version. The default value is 10. |
| 212 | RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,8,opt,name=revisionHistoryLimit"` |
| 213 | } |
| 214 | |
| 215 | // StatefulSetStatus represents the current state of a StatefulSet. |
| 216 | type StatefulSetStatus struct { |
| 217 | // observedGeneration is the most recent generation observed for this StatefulSet. It corresponds to the |
| 218 | // StatefulSet's generation, which is updated on mutation by the API Server. |
| 219 | // +optional |
| 220 | ObservedGeneration *int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"` |
| 221 | |
| 222 | // replicas is the number of Pods created by the StatefulSet controller. |
| 223 | Replicas int32 `json:"replicas" protobuf:"varint,2,opt,name=replicas"` |
| 224 | |
| 225 | // readyReplicas is the number of Pods created by the StatefulSet controller that have a Ready Condition. |
| 226 | ReadyReplicas int32 `json:"readyReplicas,omitempty" protobuf:"varint,3,opt,name=readyReplicas"` |
| 227 | |
| 228 | // currentReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version |
| 229 | // indicated by currentRevision. |
| 230 | CurrentReplicas int32 `json:"currentReplicas,omitempty" protobuf:"varint,4,opt,name=currentReplicas"` |
| 231 | |
| 232 | // updatedReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version |
| 233 | // indicated by updateRevision. |
| 234 | UpdatedReplicas int32 `json:"updatedReplicas,omitempty" protobuf:"varint,5,opt,name=updatedReplicas"` |
| 235 | |
| 236 | // currentRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the |
| 237 | // sequence [0,currentReplicas). |
| 238 | CurrentRevision string `json:"currentRevision,omitempty" protobuf:"bytes,6,opt,name=currentRevision"` |
| 239 | |
| 240 | // updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence |
| 241 | // [replicas-updatedReplicas,replicas) |
| 242 | UpdateRevision string `json:"updateRevision,omitempty" protobuf:"bytes,7,opt,name=updateRevision"` |
| 243 | |
| 244 | // collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller |
| 245 | // uses this field as a collision avoidance mechanism when it needs to create the name for the |
| 246 | // newest ControllerRevision. |
| 247 | // +optional |
| 248 | CollisionCount *int32 `json:"collisionCount,omitempty" protobuf:"varint,9,opt,name=collisionCount"` |
| 249 | |
| 250 | // Represents the latest available observations of a statefulset's current state. |
| 251 | // +optional |
| 252 | // +patchMergeKey=type |
| 253 | // +patchStrategy=merge |
| 254 | Conditions []StatefulSetCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,10,rep,name=conditions"` |
| 255 | } |
| 256 | |
| 257 | type StatefulSetConditionType string |
| 258 | |
| 259 | // StatefulSetCondition describes the state of a statefulset at a certain point. |
| 260 | type StatefulSetCondition struct { |
| 261 | // Type of statefulset condition. |
| 262 | Type StatefulSetConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=StatefulSetConditionType"` |
| 263 | // Status of the condition, one of True, False, Unknown. |
| 264 | Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"` |
| 265 | // Last time the condition transitioned from one status to another. |
| 266 | // +optional |
| 267 | LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"` |
| 268 | // The reason for the condition's last transition. |
| 269 | // +optional |
| 270 | Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"` |
| 271 | // A human readable message indicating details about the transition. |
| 272 | // +optional |
| 273 | Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"` |
| 274 | } |
| 275 | |
| 276 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 277 | |
| 278 | // StatefulSetList is a collection of StatefulSets. |
| 279 | type StatefulSetList struct { |
| 280 | metav1.TypeMeta `json:",inline"` |
| 281 | // +optional |
| 282 | metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 283 | Items []StatefulSet `json:"items" protobuf:"bytes,2,rep,name=items"` |
| 284 | } |
| 285 | |
| 286 | // +genclient |
| 287 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 288 | |
| 289 | // DEPRECATED - This group version of Deployment is deprecated by apps/v1beta2/Deployment. See the release notes for |
| 290 | // more information. |
| 291 | // Deployment enables declarative updates for Pods and ReplicaSets. |
| 292 | type Deployment struct { |
| 293 | metav1.TypeMeta `json:",inline"` |
| 294 | // Standard object metadata. |
| 295 | // +optional |
| 296 | metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 297 | |
| 298 | // Specification of the desired behavior of the Deployment. |
| 299 | // +optional |
| 300 | Spec DeploymentSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` |
| 301 | |
| 302 | // Most recently observed status of the Deployment. |
| 303 | // +optional |
| 304 | Status DeploymentStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` |
| 305 | } |
| 306 | |
| 307 | // DeploymentSpec is the specification of the desired behavior of the Deployment. |
| 308 | type DeploymentSpec struct { |
| 309 | // Number of desired pods. This is a pointer to distinguish between explicit |
| 310 | // zero and not specified. Defaults to 1. |
| 311 | // +optional |
| 312 | Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"` |
| 313 | |
| 314 | // Label selector for pods. Existing ReplicaSets whose pods are |
| 315 | // selected by this will be the ones affected by this deployment. |
| 316 | // +optional |
| 317 | Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,2,opt,name=selector"` |
| 318 | |
| 319 | // Template describes the pods that will be created. |
| 320 | Template v1.PodTemplateSpec `json:"template" protobuf:"bytes,3,opt,name=template"` |
| 321 | |
| 322 | // The deployment strategy to use to replace existing pods with new ones. |
| 323 | // +optional |
| 324 | // +patchStrategy=retainKeys |
| 325 | Strategy DeploymentStrategy `json:"strategy,omitempty" patchStrategy:"retainKeys" protobuf:"bytes,4,opt,name=strategy"` |
| 326 | |
| 327 | // Minimum number of seconds for which a newly created pod should be ready |
| 328 | // without any of its container crashing, for it to be considered available. |
| 329 | // Defaults to 0 (pod will be considered available as soon as it is ready) |
| 330 | // +optional |
| 331 | MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,5,opt,name=minReadySeconds"` |
| 332 | |
| 333 | // The number of old ReplicaSets to retain to allow rollback. |
| 334 | // This is a pointer to distinguish between explicit zero and not specified. |
| 335 | // Defaults to 2. |
| 336 | // +optional |
| 337 | RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,6,opt,name=revisionHistoryLimit"` |
| 338 | |
| 339 | // Indicates that the deployment is paused. |
| 340 | // +optional |
| 341 | Paused bool `json:"paused,omitempty" protobuf:"varint,7,opt,name=paused"` |
| 342 | |
| 343 | // DEPRECATED. |
| 344 | // The config this deployment is rolling back to. Will be cleared after rollback is done. |
| 345 | // +optional |
| 346 | RollbackTo *RollbackConfig `json:"rollbackTo,omitempty" protobuf:"bytes,8,opt,name=rollbackTo"` |
| 347 | |
| 348 | // The maximum time in seconds for a deployment to make progress before it |
| 349 | // is considered to be failed. The deployment controller will continue to |
| 350 | // process failed deployments and a condition with a ProgressDeadlineExceeded |
| 351 | // reason will be surfaced in the deployment status. Note that progress will |
| 352 | // not be estimated during the time a deployment is paused. Defaults to 600s. |
| 353 | // +optional |
| 354 | ProgressDeadlineSeconds *int32 `json:"progressDeadlineSeconds,omitempty" protobuf:"varint,9,opt,name=progressDeadlineSeconds"` |
| 355 | } |
| 356 | |
| 357 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 358 | |
| 359 | // DEPRECATED. |
| 360 | // DeploymentRollback stores the information required to rollback a deployment. |
| 361 | type DeploymentRollback struct { |
| 362 | metav1.TypeMeta `json:",inline"` |
| 363 | // Required: This must match the Name of a deployment. |
| 364 | Name string `json:"name" protobuf:"bytes,1,opt,name=name"` |
| 365 | // The annotations to be updated to a deployment |
| 366 | // +optional |
| 367 | UpdatedAnnotations map[string]string `json:"updatedAnnotations,omitempty" protobuf:"bytes,2,rep,name=updatedAnnotations"` |
| 368 | // The config of this deployment rollback. |
| 369 | RollbackTo RollbackConfig `json:"rollbackTo" protobuf:"bytes,3,opt,name=rollbackTo"` |
| 370 | } |
| 371 | |
| 372 | // DEPRECATED. |
| 373 | type RollbackConfig struct { |
| 374 | // The revision to rollback to. If set to 0, rollback to the last revision. |
| 375 | // +optional |
| 376 | Revision int64 `json:"revision,omitempty" protobuf:"varint,1,opt,name=revision"` |
| 377 | } |
| 378 | |
| 379 | const ( |
| 380 | // DefaultDeploymentUniqueLabelKey is the default key of the selector that is added |
| 381 | // to existing ReplicaSets (and label key that is added to its pods) to prevent the existing ReplicaSets |
| 382 | // to select new pods (and old pods being select by new ReplicaSet). |
| 383 | DefaultDeploymentUniqueLabelKey string = "pod-template-hash" |
| 384 | ) |
| 385 | |
| 386 | // DeploymentStrategy describes how to replace existing pods with new ones. |
| 387 | type DeploymentStrategy struct { |
| 388 | // Type of deployment. Can be "Recreate" or "RollingUpdate". Default is RollingUpdate. |
| 389 | // +optional |
| 390 | Type DeploymentStrategyType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type,casttype=DeploymentStrategyType"` |
| 391 | |
| 392 | // Rolling update config params. Present only if DeploymentStrategyType = |
| 393 | // RollingUpdate. |
| 394 | //--- |
| 395 | // TODO: Update this to follow our convention for oneOf, whatever we decide it |
| 396 | // to be. |
| 397 | // +optional |
| 398 | RollingUpdate *RollingUpdateDeployment `json:"rollingUpdate,omitempty" protobuf:"bytes,2,opt,name=rollingUpdate"` |
| 399 | } |
| 400 | |
| 401 | type DeploymentStrategyType string |
| 402 | |
| 403 | const ( |
| 404 | // Kill all existing pods before creating new ones. |
| 405 | RecreateDeploymentStrategyType DeploymentStrategyType = "Recreate" |
| 406 | |
| 407 | // Replace the old ReplicaSets by new one using rolling update i.e gradually scale down the old ReplicaSets and scale up the new one. |
| 408 | RollingUpdateDeploymentStrategyType DeploymentStrategyType = "RollingUpdate" |
| 409 | ) |
| 410 | |
| 411 | // Spec to control the desired behavior of rolling update. |
| 412 | type RollingUpdateDeployment struct { |
| 413 | // The maximum number of pods that can be unavailable during the update. |
| 414 | // Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). |
| 415 | // Absolute number is calculated from percentage by rounding down. |
| 416 | // This can not be 0 if MaxSurge is 0. |
| 417 | // Defaults to 25%. |
| 418 | // Example: when this is set to 30%, the old ReplicaSet can be scaled down to 70% of desired pods |
| 419 | // immediately when the rolling update starts. Once new pods are ready, old ReplicaSet |
| 420 | // can be scaled down further, followed by scaling up the new ReplicaSet, ensuring |
| 421 | // that the total number of pods available at all times during the update is at |
| 422 | // least 70% of desired pods. |
| 423 | // +optional |
| 424 | MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty" protobuf:"bytes,1,opt,name=maxUnavailable"` |
| 425 | |
| 426 | // The maximum number of pods that can be scheduled above the desired number of |
| 427 | // pods. |
| 428 | // Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). |
| 429 | // This can not be 0 if MaxUnavailable is 0. |
| 430 | // Absolute number is calculated from percentage by rounding up. |
| 431 | // Defaults to 25%. |
| 432 | // Example: when this is set to 30%, the new ReplicaSet can be scaled up immediately when |
| 433 | // the rolling update starts, such that the total number of old and new pods do not exceed |
| 434 | // 130% of desired pods. Once old pods have been killed, |
| 435 | // new ReplicaSet can be scaled up further, ensuring that total number of pods running |
| 436 | // at any time during the update is at most 130% of desired pods. |
| 437 | // +optional |
| 438 | MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty" protobuf:"bytes,2,opt,name=maxSurge"` |
| 439 | } |
| 440 | |
| 441 | // DeploymentStatus is the most recently observed status of the Deployment. |
| 442 | type DeploymentStatus struct { |
| 443 | // The generation observed by the deployment controller. |
| 444 | // +optional |
| 445 | ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"` |
| 446 | |
| 447 | // Total number of non-terminated pods targeted by this deployment (their labels match the selector). |
| 448 | // +optional |
| 449 | Replicas int32 `json:"replicas,omitempty" protobuf:"varint,2,opt,name=replicas"` |
| 450 | |
| 451 | // Total number of non-terminated pods targeted by this deployment that have the desired template spec. |
| 452 | // +optional |
| 453 | UpdatedReplicas int32 `json:"updatedReplicas,omitempty" protobuf:"varint,3,opt,name=updatedReplicas"` |
| 454 | |
| 455 | // Total number of ready pods targeted by this deployment. |
| 456 | // +optional |
| 457 | ReadyReplicas int32 `json:"readyReplicas,omitempty" protobuf:"varint,7,opt,name=readyReplicas"` |
| 458 | |
| 459 | // Total number of available pods (ready for at least minReadySeconds) targeted by this deployment. |
| 460 | // +optional |
| 461 | AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,4,opt,name=availableReplicas"` |
| 462 | |
| 463 | // Total number of unavailable pods targeted by this deployment. This is the total number of |
| 464 | // pods that are still required for the deployment to have 100% available capacity. They may |
| 465 | // either be pods that are running but not yet available or pods that still have not been created. |
| 466 | // +optional |
| 467 | UnavailableReplicas int32 `json:"unavailableReplicas,omitempty" protobuf:"varint,5,opt,name=unavailableReplicas"` |
| 468 | |
| 469 | // Represents the latest available observations of a deployment's current state. |
| 470 | // +patchMergeKey=type |
| 471 | // +patchStrategy=merge |
| 472 | Conditions []DeploymentCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,6,rep,name=conditions"` |
| 473 | |
| 474 | // Count of hash collisions for the Deployment. The Deployment controller uses this |
| 475 | // field as a collision avoidance mechanism when it needs to create the name for the |
| 476 | // newest ReplicaSet. |
| 477 | // +optional |
| 478 | CollisionCount *int32 `json:"collisionCount,omitempty" protobuf:"varint,8,opt,name=collisionCount"` |
| 479 | } |
| 480 | |
| 481 | type DeploymentConditionType string |
| 482 | |
| 483 | // These are valid conditions of a deployment. |
| 484 | const ( |
| 485 | // Available means the deployment is available, ie. at least the minimum available |
| 486 | // replicas required are up and running for at least minReadySeconds. |
| 487 | DeploymentAvailable DeploymentConditionType = "Available" |
| 488 | // Progressing means the deployment is progressing. Progress for a deployment is |
| 489 | // considered when a new replica set is created or adopted, and when new pods scale |
| 490 | // up or old pods scale down. Progress is not estimated for paused deployments or |
| 491 | // when progressDeadlineSeconds is not specified. |
| 492 | DeploymentProgressing DeploymentConditionType = "Progressing" |
| 493 | // ReplicaFailure is added in a deployment when one of its pods fails to be created |
| 494 | // or deleted. |
| 495 | DeploymentReplicaFailure DeploymentConditionType = "ReplicaFailure" |
| 496 | ) |
| 497 | |
| 498 | // DeploymentCondition describes the state of a deployment at a certain point. |
| 499 | type DeploymentCondition struct { |
| 500 | // Type of deployment condition. |
| 501 | Type DeploymentConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=DeploymentConditionType"` |
| 502 | // Status of the condition, one of True, False, Unknown. |
| 503 | Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"` |
| 504 | // The last time this condition was updated. |
| 505 | LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty" protobuf:"bytes,6,opt,name=lastUpdateTime"` |
| 506 | // Last time the condition transitioned from one status to another. |
| 507 | LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,7,opt,name=lastTransitionTime"` |
| 508 | // The reason for the condition's last transition. |
| 509 | Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"` |
| 510 | // A human readable message indicating details about the transition. |
| 511 | Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"` |
| 512 | } |
| 513 | |
| 514 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 515 | |
| 516 | // DeploymentList is a list of Deployments. |
| 517 | type DeploymentList struct { |
| 518 | metav1.TypeMeta `json:",inline"` |
| 519 | // Standard list metadata. |
| 520 | // +optional |
| 521 | metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 522 | |
| 523 | // Items is the list of Deployments. |
| 524 | Items []Deployment `json:"items" protobuf:"bytes,2,rep,name=items"` |
| 525 | } |
| 526 | |
| 527 | // +genclient |
| 528 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 529 | |
| 530 | // DEPRECATED - This group version of ControllerRevision is deprecated by apps/v1beta2/ControllerRevision. See the |
| 531 | // release notes for more information. |
| 532 | // ControllerRevision implements an immutable snapshot of state data. Clients |
| 533 | // are responsible for serializing and deserializing the objects that contain |
| 534 | // their internal state. |
| 535 | // Once a ControllerRevision has been successfully created, it can not be updated. |
| 536 | // The API Server will fail validation of all requests that attempt to mutate |
| 537 | // the Data field. ControllerRevisions may, however, be deleted. Note that, due to its use by both |
| 538 | // the DaemonSet and StatefulSet controllers for update and rollback, this object is beta. However, |
| 539 | // it may be subject to name and representation changes in future releases, and clients should not |
| 540 | // depend on its stability. It is primarily for internal use by controllers. |
| 541 | type ControllerRevision struct { |
| 542 | metav1.TypeMeta `json:",inline"` |
| 543 | // Standard object's metadata. |
| 544 | // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata |
| 545 | // +optional |
| 546 | metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 547 | |
| 548 | // Data is the serialized representation of the state. |
| 549 | Data runtime.RawExtension `json:"data,omitempty" protobuf:"bytes,2,opt,name=data"` |
| 550 | |
| 551 | // Revision indicates the revision of the state represented by Data. |
| 552 | Revision int64 `json:"revision" protobuf:"varint,3,opt,name=revision"` |
| 553 | } |
| 554 | |
| 555 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 556 | |
| 557 | // ControllerRevisionList is a resource containing a list of ControllerRevision objects. |
| 558 | type ControllerRevisionList struct { |
| 559 | metav1.TypeMeta `json:",inline"` |
| 560 | |
| 561 | // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata |
| 562 | // +optional |
| 563 | metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 564 | |
| 565 | // Items is the list of ControllerRevisions |
| 566 | Items []ControllerRevision `json:"items" protobuf:"bytes,2,rep,name=items"` |
| 567 | } |