...

Source file src/k8s.io/api/autoscaling/v2beta2/types.go

Documentation: k8s.io/api/autoscaling/v2beta2

     1  /*
     2  Copyright 2018 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  // +k8s:openapi-gen=true
    18  
    19  package v2beta2
    20  
    21  import (
    22  	v1 "k8s.io/api/core/v1"
    23  	"k8s.io/apimachinery/pkg/api/resource"
    24  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    25  )
    26  
    27  // +genclient
    28  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    29  // +k8s:prerelease-lifecycle-gen:introduced=1.12
    30  // +k8s:prerelease-lifecycle-gen:deprecated=1.23
    31  // +k8s:prerelease-lifecycle-gen:replacement=autoscaling,v2,HorizontalPodAutoscaler
    32  
    33  // HorizontalPodAutoscaler is the configuration for a horizontal pod
    34  // autoscaler, which automatically manages the replica count of any resource
    35  // implementing the scale subresource based on the metrics specified.
    36  type HorizontalPodAutoscaler struct {
    37  	metav1.TypeMeta `json:",inline"`
    38  	// metadata is the standard object metadata.
    39  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
    40  	// +optional
    41  	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    42  
    43  	// spec is the specification for the behaviour of the autoscaler.
    44  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status.
    45  	// +optional
    46  	Spec HorizontalPodAutoscalerSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
    47  
    48  	// status is the current information about the autoscaler.
    49  	// +optional
    50  	Status HorizontalPodAutoscalerStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
    51  }
    52  
    53  // HorizontalPodAutoscalerSpec describes the desired functionality of the HorizontalPodAutoscaler.
    54  type HorizontalPodAutoscalerSpec struct {
    55  	// scaleTargetRef points to the target resource to scale, and is used to the pods for which metrics
    56  	// should be collected, as well as to actually change the replica count.
    57  	ScaleTargetRef CrossVersionObjectReference `json:"scaleTargetRef" protobuf:"bytes,1,opt,name=scaleTargetRef"`
    58  	// minReplicas is the lower limit for the number of replicas to which the autoscaler
    59  	// can scale down.  It defaults to 1 pod.  minReplicas is allowed to be 0 if the
    60  	// alpha feature gate HPAScaleToZero is enabled and at least one Object or External
    61  	// metric is configured.  Scaling is active as long as at least one metric value is
    62  	// available.
    63  	// +optional
    64  	MinReplicas *int32 `json:"minReplicas,omitempty" protobuf:"varint,2,opt,name=minReplicas"`
    65  
    66  	// maxReplicas is the upper limit for the number of replicas to which the autoscaler can scale up.
    67  	// It cannot be less that minReplicas.
    68  	MaxReplicas int32 `json:"maxReplicas" protobuf:"varint,3,opt,name=maxReplicas"`
    69  
    70  	// metrics contains the specifications for which to use to calculate the
    71  	// desired replica count (the maximum replica count across all metrics will
    72  	// be used).  The desired replica count is calculated multiplying the
    73  	// ratio between the target value and the current value by the current
    74  	// number of pods.  Ergo, metrics used must decrease as the pod count is
    75  	// increased, and vice-versa.  See the individual metric source types for
    76  	// more information about how each type of metric must respond.
    77  	// If not set, the default metric will be set to 80% average CPU utilization.
    78  	// +optional
    79  	// +listType=atomic
    80  	Metrics []MetricSpec `json:"metrics,omitempty" protobuf:"bytes,4,rep,name=metrics"`
    81  
    82  	// behavior configures the scaling behavior of the target
    83  	// in both Up and Down directions (scaleUp and scaleDown fields respectively).
    84  	// If not set, the default HPAScalingRules for scale up and scale down are used.
    85  	// +optional
    86  	Behavior *HorizontalPodAutoscalerBehavior `json:"behavior,omitempty" protobuf:"bytes,5,opt,name=behavior"`
    87  }
    88  
    89  // CrossVersionObjectReference contains enough information to let you identify the referred resource.
    90  type CrossVersionObjectReference struct {
    91  	// kind is the kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
    92  	Kind string `json:"kind" protobuf:"bytes,1,opt,name=kind"`
    93  
    94  	// name is the name of the referent; More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
    95  	Name string `json:"name" protobuf:"bytes,2,opt,name=name"`
    96  
    97  	// apiVersion is the API version of the referent
    98  	// +optional
    99  	APIVersion string `json:"apiVersion,omitempty" protobuf:"bytes,3,opt,name=apiVersion"`
   100  }
   101  
   102  // MetricSpec specifies how to scale based on a single metric
   103  // (only `type` and one other matching field should be set at once).
   104  type MetricSpec struct {
   105  	// type is the type of metric source.  It should be one of "ContainerResource", "External",
   106  	// "Object", "Pods" or "Resource", each mapping to a matching field in the object.
   107  	// Note: "ContainerResource" type is available on when the feature-gate
   108  	// HPAContainerMetrics is enabled
   109  	Type MetricSourceType `json:"type" protobuf:"bytes,1,name=type"`
   110  
   111  	// object refers to a metric describing a single kubernetes object
   112  	// (for example, hits-per-second on an Ingress object).
   113  	// +optional
   114  	Object *ObjectMetricSource `json:"object,omitempty" protobuf:"bytes,2,opt,name=object"`
   115  
   116  	// pods refers to a metric describing each pod in the current scale target
   117  	// (for example, transactions-processed-per-second).  The values will be
   118  	// averaged together before being compared to the target value.
   119  	// +optional
   120  	Pods *PodsMetricSource `json:"pods,omitempty" protobuf:"bytes,3,opt,name=pods"`
   121  
   122  	// resource refers to a resource metric (such as those specified in
   123  	// requests and limits) known to Kubernetes describing each pod in the
   124  	// current scale target (e.g. CPU or memory). Such metrics are built in to
   125  	// Kubernetes, and have special scaling options on top of those available
   126  	// to normal per-pod metrics using the "pods" source.
   127  	// +optional
   128  	Resource *ResourceMetricSource `json:"resource,omitempty" protobuf:"bytes,4,opt,name=resource"`
   129  
   130  	// container resource refers to a resource metric (such as those specified in
   131  	// requests and limits) known to Kubernetes describing a single container in
   132  	// each pod of the current scale target (e.g. CPU or memory). Such metrics are
   133  	// built in to Kubernetes, and have special scaling options on top of those
   134  	// available to normal per-pod metrics using the "pods" source.
   135  	// This is an alpha feature and can be enabled by the HPAContainerMetrics feature flag.
   136  	// +optional
   137  	ContainerResource *ContainerResourceMetricSource `json:"containerResource,omitempty" protobuf:"bytes,7,opt,name=containerResource"`
   138  
   139  	// external refers to a global metric that is not associated
   140  	// with any Kubernetes object. It allows autoscaling based on information
   141  	// coming from components running outside of cluster
   142  	// (for example length of queue in cloud messaging service, or
   143  	// QPS from loadbalancer running outside of cluster).
   144  	// +optional
   145  	External *ExternalMetricSource `json:"external,omitempty" protobuf:"bytes,5,opt,name=external"`
   146  }
   147  
   148  // HorizontalPodAutoscalerBehavior configures the scaling behavior of the target
   149  // in both Up and Down directions (scaleUp and scaleDown fields respectively).
   150  type HorizontalPodAutoscalerBehavior struct {
   151  	// scaleUp is scaling policy for scaling Up.
   152  	// If not set, the default value is the higher of:
   153  	//   * increase no more than 4 pods per 60 seconds
   154  	//   * double the number of pods per 60 seconds
   155  	// No stabilization is used.
   156  	// +optional
   157  	ScaleUp *HPAScalingRules `json:"scaleUp,omitempty" protobuf:"bytes,1,opt,name=scaleUp"`
   158  
   159  	// scaleDown is scaling policy for scaling Down.
   160  	// If not set, the default value is to allow to scale down to minReplicas pods, with a
   161  	// 300 second stabilization window (i.e., the highest recommendation for
   162  	// the last 300sec is used).
   163  	// +optional
   164  	ScaleDown *HPAScalingRules `json:"scaleDown,omitempty" protobuf:"bytes,2,opt,name=scaleDown"`
   165  }
   166  
   167  // ScalingPolicySelect is used to specify which policy should be used while scaling in a certain direction
   168  type ScalingPolicySelect string
   169  
   170  const (
   171  	// MaxPolicySelect selects the policy with the highest possible change.
   172  	MaxPolicySelect ScalingPolicySelect = "Max"
   173  	// MinPolicySelect selects the policy with the lowest possible change.
   174  	MinPolicySelect ScalingPolicySelect = "Min"
   175  	// DisabledPolicySelect disables the scaling in this direction.
   176  	DisabledPolicySelect ScalingPolicySelect = "Disabled"
   177  )
   178  
   179  // HPAScalingRules configures the scaling behavior for one direction.
   180  // These Rules are applied after calculating DesiredReplicas from metrics for the HPA.
   181  // They can limit the scaling velocity by specifying scaling policies.
   182  // They can prevent flapping by specifying the stabilization window, so that the
   183  // number of replicas is not set instantly, instead, the safest value from the stabilization
   184  // window is chosen.
   185  type HPAScalingRules struct {
   186  	// stabilizationWindowSeconds is the number of seconds for which past recommendations should be
   187  	// considered while scaling up or scaling down.
   188  	// StabilizationWindowSeconds must be greater than or equal to zero and less than or equal to 3600 (one hour).
   189  	// If not set, use the default values:
   190  	// - For scale up: 0 (i.e. no stabilization is done).
   191  	// - For scale down: 300 (i.e. the stabilization window is 300 seconds long).
   192  	// +optional
   193  	StabilizationWindowSeconds *int32 `json:"stabilizationWindowSeconds,omitempty" protobuf:"varint,3,opt,name=stabilizationWindowSeconds"`
   194  
   195  	// selectPolicy is used to specify which policy should be used.
   196  	// If not set, the default value MaxPolicySelect is used.
   197  	// +optional
   198  	SelectPolicy *ScalingPolicySelect `json:"selectPolicy,omitempty" protobuf:"bytes,1,opt,name=selectPolicy"`
   199  
   200  	// policies is a list of potential scaling polices which can be used during scaling.
   201  	// At least one policy must be specified, otherwise the HPAScalingRules will be discarded as invalid
   202  	// +optional
   203  	// +listType=atomic
   204  	Policies []HPAScalingPolicy `json:"policies,omitempty" protobuf:"bytes,2,rep,name=policies"`
   205  }
   206  
   207  // HPAScalingPolicyType is the type of the policy which could be used while making scaling decisions.
   208  type HPAScalingPolicyType string
   209  
   210  const (
   211  	// PodsScalingPolicy is a policy used to specify a change in absolute number of pods.
   212  	PodsScalingPolicy HPAScalingPolicyType = "Pods"
   213  	// PercentScalingPolicy is a policy used to specify a relative amount of change with respect to
   214  	// the current number of pods.
   215  	PercentScalingPolicy HPAScalingPolicyType = "Percent"
   216  )
   217  
   218  // HPAScalingPolicy is a single policy which must hold true for a specified past interval.
   219  type HPAScalingPolicy struct {
   220  	// type is used to specify the scaling policy.
   221  	Type HPAScalingPolicyType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=HPAScalingPolicyType"`
   222  
   223  	// value contains the amount of change which is permitted by the policy.
   224  	// It must be greater than zero
   225  	Value int32 `json:"value" protobuf:"varint,2,opt,name=value"`
   226  
   227  	// periodSeconds specifies the window of time for which the policy should hold true.
   228  	// PeriodSeconds must be greater than zero and less than or equal to 1800 (30 min).
   229  	PeriodSeconds int32 `json:"periodSeconds" protobuf:"varint,3,opt,name=periodSeconds"`
   230  }
   231  
   232  // MetricSourceType indicates the type of metric.
   233  type MetricSourceType string
   234  
   235  const (
   236  	// ObjectMetricSourceType is a metric describing a kubernetes object
   237  	// (for example, hits-per-second on an Ingress object).
   238  	ObjectMetricSourceType MetricSourceType = "Object"
   239  	// PodsMetricSourceType is a metric describing each pod in the current scale
   240  	// target (for example, transactions-processed-per-second).  The values
   241  	// will be averaged together before being compared to the target value.
   242  	PodsMetricSourceType MetricSourceType = "Pods"
   243  	// ResourceMetricSourceType is a resource metric known to Kubernetes, as
   244  	// specified in requests and limits, describing each pod in the current
   245  	// scale target (e.g. CPU or memory).  Such metrics are built in to
   246  	// Kubernetes, and have special scaling options on top of those available
   247  	// to normal per-pod metrics (the "pods" source).
   248  	ResourceMetricSourceType MetricSourceType = "Resource"
   249  	// ContainerResourceMetricSourceType is a resource metric known to Kubernetes, as
   250  	// specified in requests and limits, describing a single container in each pod in the current
   251  	// scale target (e.g. CPU or memory).  Such metrics are built in to
   252  	// Kubernetes, and have special scaling options on top of those available
   253  	// to normal per-pod metrics (the "pods" source).
   254  	ContainerResourceMetricSourceType MetricSourceType = "ContainerResource"
   255  	// ExternalMetricSourceType is a global metric that is not associated
   256  	// with any Kubernetes object. It allows autoscaling based on information
   257  	// coming from components running outside of cluster
   258  	// (for example length of queue in cloud messaging service, or
   259  	// QPS from loadbalancer running outside of cluster).
   260  	ExternalMetricSourceType MetricSourceType = "External"
   261  )
   262  
   263  // ObjectMetricSource indicates how to scale on a metric describing a
   264  // kubernetes object (for example, hits-per-second on an Ingress object).
   265  type ObjectMetricSource struct {
   266  	DescribedObject CrossVersionObjectReference `json:"describedObject" protobuf:"bytes,1,name=describedObject"`
   267  	// target specifies the target value for the given metric
   268  	Target MetricTarget `json:"target" protobuf:"bytes,2,name=target"`
   269  
   270  	// metric identifies the target metric by name and selector
   271  	Metric MetricIdentifier `json:"metric" protobuf:"bytes,3,name=metric"`
   272  }
   273  
   274  // PodsMetricSource indicates how to scale on a metric describing each pod in
   275  // the current scale target (for example, transactions-processed-per-second).
   276  // The values will be averaged together before being compared to the target
   277  // value.
   278  type PodsMetricSource struct {
   279  	// metric identifies the target metric by name and selector
   280  	Metric MetricIdentifier `json:"metric" protobuf:"bytes,1,name=metric"`
   281  
   282  	// target specifies the target value for the given metric
   283  	Target MetricTarget `json:"target" protobuf:"bytes,2,name=target"`
   284  }
   285  
   286  // ResourceMetricSource indicates how to scale on a resource metric known to
   287  // Kubernetes, as specified in requests and limits, describing each pod in the
   288  // current scale target (e.g. CPU or memory).  The values will be averaged
   289  // together before being compared to the target.  Such metrics are built in to
   290  // Kubernetes, and have special scaling options on top of those available to
   291  // normal per-pod metrics using the "pods" source.  Only one "target" type
   292  // should be set.
   293  type ResourceMetricSource struct {
   294  	// name is the name of the resource in question.
   295  	Name v1.ResourceName `json:"name" protobuf:"bytes,1,name=name"`
   296  
   297  	// target specifies the target value for the given metric
   298  	Target MetricTarget `json:"target" protobuf:"bytes,2,name=target"`
   299  }
   300  
   301  // ContainerResourceMetricSource indicates how to scale on a resource metric known to
   302  // Kubernetes, as specified in requests and limits, describing each pod in the
   303  // current scale target (e.g. CPU or memory).  The values will be averaged
   304  // together before being compared to the target.  Such metrics are built in to
   305  // Kubernetes, and have special scaling options on top of those available to
   306  // normal per-pod metrics using the "pods" source.  Only one "target" type
   307  // should be set.
   308  type ContainerResourceMetricSource struct {
   309  	// name is the name of the resource in question.
   310  	Name v1.ResourceName `json:"name" protobuf:"bytes,1,name=name"`
   311  
   312  	// target specifies the target value for the given metric
   313  	Target MetricTarget `json:"target" protobuf:"bytes,2,name=target"`
   314  
   315  	// container is the name of the container in the pods of the scaling target
   316  	Container string `json:"container" protobuf:"bytes,3,opt,name=container"`
   317  }
   318  
   319  // ExternalMetricSource indicates how to scale on a metric not associated with
   320  // any Kubernetes object (for example length of queue in cloud
   321  // messaging service, or QPS from loadbalancer running outside of cluster).
   322  type ExternalMetricSource struct {
   323  	// metric identifies the target metric by name and selector
   324  	Metric MetricIdentifier `json:"metric" protobuf:"bytes,1,name=metric"`
   325  
   326  	// target specifies the target value for the given metric
   327  	Target MetricTarget `json:"target" protobuf:"bytes,2,name=target"`
   328  }
   329  
   330  // MetricIdentifier defines the name and optionally selector for a metric
   331  type MetricIdentifier struct {
   332  	// name is the name of the given metric
   333  	Name string `json:"name" protobuf:"bytes,1,name=name"`
   334  
   335  	// selector is the string-encoded form of a standard kubernetes label selector for the given metric
   336  	// When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping.
   337  	// When unset, just the metricName will be used to gather metrics.
   338  	// +optional
   339  	Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,2,name=selector"`
   340  }
   341  
   342  // MetricTarget defines the target value, average value, or average utilization of a specific metric
   343  type MetricTarget struct {
   344  	// type represents whether the metric type is Utilization, Value, or AverageValue
   345  	Type MetricTargetType `json:"type" protobuf:"bytes,1,name=type"`
   346  
   347  	// value is the target value of the metric (as a quantity).
   348  	// +optional
   349  	Value *resource.Quantity `json:"value,omitempty" protobuf:"bytes,2,opt,name=value"`
   350  
   351  	// averageValue is the target value of the average of the
   352  	// metric across all relevant pods (as a quantity)
   353  	// +optional
   354  	AverageValue *resource.Quantity `json:"averageValue,omitempty" protobuf:"bytes,3,opt,name=averageValue"`
   355  
   356  	// averageUtilization is the target value of the average of the
   357  	// resource metric across all relevant pods, represented as a percentage of
   358  	// the requested value of the resource for the pods.
   359  	// Currently only valid for Resource metric source type
   360  	// +optional
   361  	AverageUtilization *int32 `json:"averageUtilization,omitempty" protobuf:"bytes,4,opt,name=averageUtilization"`
   362  }
   363  
   364  // MetricTargetType specifies the type of metric being targeted, and should be either
   365  // "Value", "AverageValue", or "Utilization"
   366  type MetricTargetType string
   367  
   368  const (
   369  	// UtilizationMetricType declares a MetricTarget is an AverageUtilization value
   370  	UtilizationMetricType MetricTargetType = "Utilization"
   371  	// ValueMetricType declares a MetricTarget is a raw value
   372  	ValueMetricType MetricTargetType = "Value"
   373  	// AverageValueMetricType declares a MetricTarget is an
   374  	AverageValueMetricType MetricTargetType = "AverageValue"
   375  )
   376  
   377  // HorizontalPodAutoscalerStatus describes the current status of a horizontal pod autoscaler.
   378  type HorizontalPodAutoscalerStatus struct {
   379  	// observedGeneration is the most recent generation observed by this autoscaler.
   380  	// +optional
   381  	ObservedGeneration *int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"`
   382  
   383  	// lastScaleTime is the last time the HorizontalPodAutoscaler scaled the number of pods,
   384  	// used by the autoscaler to control how often the number of pods is changed.
   385  	// +optional
   386  	LastScaleTime *metav1.Time `json:"lastScaleTime,omitempty" protobuf:"bytes,2,opt,name=lastScaleTime"`
   387  
   388  	// currentReplicas is current number of replicas of pods managed by this autoscaler,
   389  	// as last seen by the autoscaler.
   390  	CurrentReplicas int32 `json:"currentReplicas" protobuf:"varint,3,opt,name=currentReplicas"`
   391  
   392  	// desiredReplicas is the desired number of replicas of pods managed by this autoscaler,
   393  	// as last calculated by the autoscaler.
   394  	DesiredReplicas int32 `json:"desiredReplicas" protobuf:"varint,4,opt,name=desiredReplicas"`
   395  
   396  	// currentMetrics is the last read state of the metrics used by this autoscaler.
   397  	// +optional
   398  	// +listType=atomic
   399  	CurrentMetrics []MetricStatus `json:"currentMetrics" protobuf:"bytes,5,rep,name=currentMetrics"`
   400  
   401  	// conditions is the set of conditions required for this autoscaler to scale its target,
   402  	// and indicates whether or not those conditions are met.
   403  	// +optional
   404  	// +listType=atomic
   405  	Conditions []HorizontalPodAutoscalerCondition `json:"conditions" protobuf:"bytes,6,rep,name=conditions"`
   406  }
   407  
   408  // HorizontalPodAutoscalerConditionType are the valid conditions of
   409  // a HorizontalPodAutoscaler.
   410  type HorizontalPodAutoscalerConditionType string
   411  
   412  const (
   413  	// ScalingActive indicates that the HPA controller is able to scale if necessary:
   414  	// it's correctly configured, can fetch the desired metrics, and isn't disabled.
   415  	ScalingActive HorizontalPodAutoscalerConditionType = "ScalingActive"
   416  	// AbleToScale indicates a lack of transient issues which prevent scaling from occurring,
   417  	// such as being in a backoff window, or being unable to access/update the target scale.
   418  	AbleToScale HorizontalPodAutoscalerConditionType = "AbleToScale"
   419  	// ScalingLimited indicates that the calculated scale based on metrics would be above or
   420  	// below the range for the HPA, and has thus been capped.
   421  	ScalingLimited HorizontalPodAutoscalerConditionType = "ScalingLimited"
   422  )
   423  
   424  // HorizontalPodAutoscalerCondition describes the state of
   425  // a HorizontalPodAutoscaler at a certain point.
   426  type HorizontalPodAutoscalerCondition struct {
   427  	// type describes the current condition
   428  	Type HorizontalPodAutoscalerConditionType `json:"type" protobuf:"bytes,1,name=type"`
   429  
   430  	// status is the status of the condition (True, False, Unknown)
   431  	Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,name=status"`
   432  
   433  	// lastTransitionTime is the last time the condition transitioned from
   434  	// one status to another
   435  	// +optional
   436  	LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"`
   437  
   438  	// reason is the reason for the condition's last transition.
   439  	// +optional
   440  	Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
   441  
   442  	// message is a human-readable explanation containing details about
   443  	// the transition
   444  	// +optional
   445  	Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
   446  }
   447  
   448  // MetricStatus describes the last-read state of a single metric.
   449  type MetricStatus struct {
   450  	// type is the type of metric source.  It will be one of "ContainerResource", "External",
   451  	// "Object", "Pods" or "Resource", each corresponds to a matching field in the object.
   452  	// Note: "ContainerResource" type is available on when the feature-gate
   453  	// HPAContainerMetrics is enabled
   454  	Type MetricSourceType `json:"type" protobuf:"bytes,1,name=type"`
   455  
   456  	// object refers to a metric describing a single kubernetes object
   457  	// (for example, hits-per-second on an Ingress object).
   458  	// +optional
   459  	Object *ObjectMetricStatus `json:"object,omitempty" protobuf:"bytes,2,opt,name=object"`
   460  
   461  	// pods refers to a metric describing each pod in the current scale target
   462  	// (for example, transactions-processed-per-second).  The values will be
   463  	// averaged together before being compared to the target value.
   464  	// +optional
   465  	Pods *PodsMetricStatus `json:"pods,omitempty" protobuf:"bytes,3,opt,name=pods"`
   466  	// resource refers to a resource metric (such as those specified in
   467  	// requests and limits) known to Kubernetes describing each pod in the
   468  	// current scale target (e.g. CPU or memory). Such metrics are built in to
   469  	// Kubernetes, and have special scaling options on top of those available
   470  	// to normal per-pod metrics using the "pods" source.
   471  	// +optional
   472  	Resource *ResourceMetricStatus `json:"resource,omitempty" protobuf:"bytes,4,opt,name=resource"`
   473  
   474  	// containerResource refers to a resource metric (such as those specified in
   475  	// requests and limits) known to Kubernetes describing a single container in each pod in the
   476  	// current scale target (e.g. CPU or memory). Such metrics are built in to
   477  	// Kubernetes, and have special scaling options on top of those available
   478  	// to normal per-pod metrics using the "pods" source.
   479  	// +optional
   480  	ContainerResource *ContainerResourceMetricStatus `json:"containerResource,omitempty" protobuf:"bytes,7,opt,name=containerResource"`
   481  
   482  	// external refers to a global metric that is not associated
   483  	// with any Kubernetes object. It allows autoscaling based on information
   484  	// coming from components running outside of cluster
   485  	// (for example length of queue in cloud messaging service, or
   486  	// QPS from loadbalancer running outside of cluster).
   487  	// +optional
   488  	External *ExternalMetricStatus `json:"external,omitempty" protobuf:"bytes,5,opt,name=external"`
   489  }
   490  
   491  // ObjectMetricStatus indicates the current value of a metric describing a
   492  // kubernetes object (for example, hits-per-second on an Ingress object).
   493  type ObjectMetricStatus struct {
   494  	// metric identifies the target metric by name and selector
   495  	Metric MetricIdentifier `json:"metric" protobuf:"bytes,1,name=metric"`
   496  
   497  	// current contains the current value for the given metric
   498  	Current MetricValueStatus `json:"current" protobuf:"bytes,2,name=current"`
   499  
   500  	DescribedObject CrossVersionObjectReference `json:"describedObject" protobuf:"bytes,3,name=describedObject"`
   501  }
   502  
   503  // PodsMetricStatus indicates the current value of a metric describing each pod in
   504  // the current scale target (for example, transactions-processed-per-second).
   505  type PodsMetricStatus struct {
   506  	// metric identifies the target metric by name and selector
   507  	Metric MetricIdentifier `json:"metric" protobuf:"bytes,1,name=metric"`
   508  
   509  	// current contains the current value for the given metric
   510  	Current MetricValueStatus `json:"current" protobuf:"bytes,2,name=current"`
   511  }
   512  
   513  // ResourceMetricStatus indicates the current value of a resource metric known to
   514  // Kubernetes, as specified in requests and limits, describing each pod in the
   515  // current scale target (e.g. CPU or memory).  Such metrics are built in to
   516  // Kubernetes, and have special scaling options on top of those available to
   517  // normal per-pod metrics using the "pods" source.
   518  type ResourceMetricStatus struct {
   519  	// name is the name of the resource in question.
   520  	Name v1.ResourceName `json:"name" protobuf:"bytes,1,name=name"`
   521  
   522  	// current contains the current value for the given metric
   523  	Current MetricValueStatus `json:"current" protobuf:"bytes,2,name=current"`
   524  }
   525  
   526  // ContainerResourceMetricStatus indicates the current value of a resource metric known to
   527  // Kubernetes, as specified in requests and limits, describing a single container in each pod in the
   528  // current scale target (e.g. CPU or memory).  Such metrics are built in to
   529  // Kubernetes, and have special scaling options on top of those available to
   530  // normal per-pod metrics using the "pods" source.
   531  type ContainerResourceMetricStatus struct {
   532  	// name is the name of the resource in question.
   533  	Name v1.ResourceName `json:"name" protobuf:"bytes,1,name=name"`
   534  
   535  	// current contains the current value for the given metric
   536  	Current MetricValueStatus `json:"current" protobuf:"bytes,2,name=current"`
   537  
   538  	// container is the name of the container in the pods of the scaling target
   539  	Container string `json:"container" protobuf:"bytes,3,opt,name=container"`
   540  }
   541  
   542  // ExternalMetricStatus indicates the current value of a global metric
   543  // not associated with any Kubernetes object.
   544  type ExternalMetricStatus struct {
   545  	// metric identifies the target metric by name and selector
   546  	Metric MetricIdentifier `json:"metric" protobuf:"bytes,1,name=metric"`
   547  
   548  	// current contains the current value for the given metric
   549  	Current MetricValueStatus `json:"current" protobuf:"bytes,2,name=current"`
   550  }
   551  
   552  // MetricValueStatus holds the current value for a metric
   553  type MetricValueStatus struct {
   554  	// value is the current value of the metric (as a quantity).
   555  	// +optional
   556  	Value *resource.Quantity `json:"value,omitempty" protobuf:"bytes,1,opt,name=value"`
   557  
   558  	// averageValue is the current value of the average of the
   559  	// metric across all relevant pods (as a quantity)
   560  	// +optional
   561  	AverageValue *resource.Quantity `json:"averageValue,omitempty" protobuf:"bytes,2,opt,name=averageValue"`
   562  
   563  	// averageUtilization is the current value of the average of the
   564  	// resource metric across all relevant pods, represented as a percentage of
   565  	// the requested value of the resource for the pods.
   566  	// +optional
   567  	AverageUtilization *int32 `json:"averageUtilization,omitempty" protobuf:"bytes,3,opt,name=averageUtilization"`
   568  }
   569  
   570  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   571  // +k8s:prerelease-lifecycle-gen:introduced=1.12
   572  // +k8s:prerelease-lifecycle-gen:deprecated=1.22
   573  
   574  // HorizontalPodAutoscalerList is a list of horizontal pod autoscaler objects.
   575  type HorizontalPodAutoscalerList struct {
   576  	metav1.TypeMeta `json:",inline"`
   577  	// metadata is the standard list metadata.
   578  	// +optional
   579  	metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
   580  
   581  	// items is the list of horizontal pod autoscaler objects.
   582  	Items []HorizontalPodAutoscaler `json:"items" protobuf:"bytes,2,rep,name=items"`
   583  }
   584  

View as plain text