...

Source file src/k8s.io/kubernetes/pkg/apis/apps/types.go

Documentation: k8s.io/kubernetes/pkg/apis/apps

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

View as plain text