...

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

Documentation: k8s.io/api/autoscaling/v1

     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 v1
    18  
    19  import (
    20  	v1 "k8s.io/api/core/v1"
    21  	"k8s.io/apimachinery/pkg/api/resource"
    22  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    23  )
    24  
    25  // CrossVersionObjectReference contains enough information to let you identify the referred resource.
    26  // +structType=atomic
    27  type CrossVersionObjectReference struct {
    28  	// kind is the kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
    29  	Kind string `json:"kind" protobuf:"bytes,1,opt,name=kind"`
    30  
    31  	// name is the name of the referent; More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
    32  	Name string `json:"name" protobuf:"bytes,2,opt,name=name"`
    33  
    34  	// apiVersion is the API version of the referent
    35  	// +optional
    36  	APIVersion string `json:"apiVersion,omitempty" protobuf:"bytes,3,opt,name=apiVersion"`
    37  }
    38  
    39  // specification of a horizontal pod autoscaler.
    40  type HorizontalPodAutoscalerSpec struct {
    41  	// reference to scaled resource; horizontal pod autoscaler will learn the current resource consumption
    42  	// and will set the desired number of pods by using its Scale subresource.
    43  	ScaleTargetRef CrossVersionObjectReference `json:"scaleTargetRef" protobuf:"bytes,1,opt,name=scaleTargetRef"`
    44  	// minReplicas is the lower limit for the number of replicas to which the autoscaler
    45  	// can scale down.  It defaults to 1 pod.  minReplicas is allowed to be 0 if the
    46  	// alpha feature gate HPAScaleToZero is enabled and at least one Object or External
    47  	// metric is configured.  Scaling is active as long as at least one metric value is
    48  	// available.
    49  	// +optional
    50  	MinReplicas *int32 `json:"minReplicas,omitempty" protobuf:"varint,2,opt,name=minReplicas"`
    51  
    52  	// maxReplicas is the upper limit for the number of pods that can be set by the autoscaler; cannot be smaller than MinReplicas.
    53  	MaxReplicas int32 `json:"maxReplicas" protobuf:"varint,3,opt,name=maxReplicas"`
    54  
    55  	// targetCPUUtilizationPercentage is the target average CPU utilization (represented as a percentage of requested CPU) over all the pods;
    56  	// if not specified the default autoscaling policy will be used.
    57  	// +optional
    58  	TargetCPUUtilizationPercentage *int32 `json:"targetCPUUtilizationPercentage,omitempty" protobuf:"varint,4,opt,name=targetCPUUtilizationPercentage"`
    59  }
    60  
    61  // current status of a horizontal pod autoscaler
    62  type HorizontalPodAutoscalerStatus struct {
    63  	// observedGeneration is the most recent generation observed by this autoscaler.
    64  	// +optional
    65  	ObservedGeneration *int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"`
    66  
    67  	// lastScaleTime is the last time the HorizontalPodAutoscaler scaled the number of pods;
    68  	// used by the autoscaler to control how often the number of pods is changed.
    69  	// +optional
    70  	LastScaleTime *metav1.Time `json:"lastScaleTime,omitempty" protobuf:"bytes,2,opt,name=lastScaleTime"`
    71  
    72  	// currentReplicas is the current number of replicas of pods managed by this autoscaler.
    73  	CurrentReplicas int32 `json:"currentReplicas" protobuf:"varint,3,opt,name=currentReplicas"`
    74  
    75  	// desiredReplicas is the  desired number of replicas of pods managed by this autoscaler.
    76  	DesiredReplicas int32 `json:"desiredReplicas" protobuf:"varint,4,opt,name=desiredReplicas"`
    77  
    78  	// currentCPUUtilizationPercentage is the current average CPU utilization over all pods, represented as a percentage of requested CPU,
    79  	// e.g. 70 means that an average pod is using now 70% of its requested CPU.
    80  	// +optional
    81  	CurrentCPUUtilizationPercentage *int32 `json:"currentCPUUtilizationPercentage,omitempty" protobuf:"varint,5,opt,name=currentCPUUtilizationPercentage"`
    82  }
    83  
    84  // +genclient
    85  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    86  
    87  // configuration of a horizontal pod autoscaler.
    88  type HorizontalPodAutoscaler struct {
    89  	metav1.TypeMeta `json:",inline"`
    90  	// Standard object metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
    91  	// +optional
    92  	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    93  
    94  	// spec defines the behaviour of autoscaler. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status.
    95  	// +optional
    96  	Spec HorizontalPodAutoscalerSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
    97  
    98  	// status is the current information about the autoscaler.
    99  	// +optional
   100  	Status HorizontalPodAutoscalerStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
   101  }
   102  
   103  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   104  
   105  // list of horizontal pod autoscaler objects.
   106  type HorizontalPodAutoscalerList struct {
   107  	metav1.TypeMeta `json:",inline"`
   108  	// Standard list metadata.
   109  	// +optional
   110  	metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
   111  
   112  	// items is the list of horizontal pod autoscaler objects.
   113  	Items []HorizontalPodAutoscaler `json:"items" protobuf:"bytes,2,rep,name=items"`
   114  }
   115  
   116  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   117  
   118  // Scale represents a scaling request for a resource.
   119  type Scale struct {
   120  	metav1.TypeMeta `json:",inline"`
   121  	// Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata.
   122  	// +optional
   123  	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
   124  
   125  	// spec defines the behavior of the scale. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status.
   126  	// +optional
   127  	Spec ScaleSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
   128  
   129  	// status is the current status of the scale. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status. Read-only.
   130  	// +optional
   131  	Status ScaleStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
   132  }
   133  
   134  // ScaleSpec describes the attributes of a scale subresource.
   135  type ScaleSpec struct {
   136  	// replicas is the desired number of instances for the scaled object.
   137  	// +optional
   138  	Replicas int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
   139  }
   140  
   141  // ScaleStatus represents the current status of a scale subresource.
   142  type ScaleStatus struct {
   143  	// replicas is the actual number of observed instances of the scaled object.
   144  	Replicas int32 `json:"replicas" protobuf:"varint,1,opt,name=replicas"`
   145  
   146  	// selector is the label query over pods that should match the replicas count. This is same
   147  	// as the label selector but in the string format to avoid introspection
   148  	// by clients. The string will be in the same format as the query-param syntax.
   149  	// More info about label selectors: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
   150  	// +optional
   151  	Selector string `json:"selector,omitempty" protobuf:"bytes,2,opt,name=selector"`
   152  }
   153  
   154  // the types below are used in the alpha metrics annotation
   155  
   156  // MetricSourceType indicates the type of metric.
   157  // +enum
   158  type MetricSourceType string
   159  
   160  const (
   161  	// ObjectMetricSourceType is a metric describing a kubernetes object
   162  	// (for example, hits-per-second on an Ingress object).
   163  	ObjectMetricSourceType MetricSourceType = "Object"
   164  	// PodsMetricSourceType is a metric describing each pod in the current scale
   165  	// target (for example, transactions-processed-per-second).  The values
   166  	// will be averaged together before being compared to the target value.
   167  	PodsMetricSourceType MetricSourceType = "Pods"
   168  	// ResourceMetricSourceType is a resource metric known to Kubernetes, as
   169  	// specified in requests and limits, describing each pod in the current
   170  	// scale target (e.g. CPU or memory).  Such metrics are built in to
   171  	// Kubernetes, and have special scaling options on top of those available
   172  	// to normal per-pod metrics (the "pods" source).
   173  	ResourceMetricSourceType MetricSourceType = "Resource"
   174  	// ContainerResourceMetricSourceType is a resource metric known to Kubernetes, as
   175  	// specified in requests and limits, describing a single container in each pod in the current
   176  	// scale target (e.g. CPU or memory).  Such metrics are built in to
   177  	// Kubernetes, and have special scaling options on top of those available
   178  	// to normal per-pod metrics (the "pods" source).
   179  	ContainerResourceMetricSourceType MetricSourceType = "ContainerResource"
   180  	// ExternalMetricSourceType is a global metric that is not associated
   181  	// with any Kubernetes object. It allows autoscaling based on information
   182  	// coming from components running outside of cluster
   183  	// (for example length of queue in cloud messaging service, or
   184  	// QPS from loadbalancer running outside of cluster).
   185  	ExternalMetricSourceType MetricSourceType = "External"
   186  )
   187  
   188  // MetricSpec specifies how to scale based on a single metric
   189  // (only `type` and one other matching field should be set at once).
   190  type MetricSpec struct {
   191  	// type is the type of metric source.  It should be one of "ContainerResource",
   192  	// "External", "Object", "Pods" or "Resource", each mapping to a matching field in the object.
   193  	// Note: "ContainerResource" type is available on when the feature-gate
   194  	// HPAContainerMetrics is enabled
   195  	Type MetricSourceType `json:"type" protobuf:"bytes,1,name=type"`
   196  
   197  	// object refers to a metric describing a single kubernetes object
   198  	// (for example, hits-per-second on an Ingress object).
   199  	// +optional
   200  	Object *ObjectMetricSource `json:"object,omitempty" protobuf:"bytes,2,opt,name=object"`
   201  
   202  	// pods refers to a metric describing each pod in the current scale target
   203  	// (for example, transactions-processed-per-second).  The values will be
   204  	// averaged together before being compared to the target value.
   205  	// +optional
   206  	Pods *PodsMetricSource `json:"pods,omitempty" protobuf:"bytes,3,opt,name=pods"`
   207  
   208  	// resource refers to a resource metric (such as those specified in
   209  	// requests and limits) known to Kubernetes describing each pod in the
   210  	// current scale target (e.g. CPU or memory). Such metrics are built in to
   211  	// Kubernetes, and have special scaling options on top of those available
   212  	// to normal per-pod metrics using the "pods" source.
   213  	// +optional
   214  	Resource *ResourceMetricSource `json:"resource,omitempty" protobuf:"bytes,4,opt,name=resource"`
   215  
   216  	// containerResource refers to a resource metric (such as those specified in
   217  	// requests and limits) known to Kubernetes describing a single container in each pod of the
   218  	// current scale target (e.g. CPU or memory). Such metrics are built in to
   219  	// Kubernetes, and have special scaling options on top of those available
   220  	// to normal per-pod metrics using the "pods" source.
   221  	// This is an alpha feature and can be enabled by the HPAContainerMetrics feature flag.
   222  	// +optional
   223  	ContainerResource *ContainerResourceMetricSource `json:"containerResource,omitempty" protobuf:"bytes,7,opt,name=containerResource"`
   224  
   225  	// external refers to a global metric that is not associated
   226  	// with any Kubernetes object. It allows autoscaling based on information
   227  	// coming from components running outside of cluster
   228  	// (for example length of queue in cloud messaging service, or
   229  	// QPS from loadbalancer running outside of cluster).
   230  	// +optional
   231  	External *ExternalMetricSource `json:"external,omitempty" protobuf:"bytes,5,opt,name=external"`
   232  }
   233  
   234  // ObjectMetricSource indicates how to scale on a metric describing a
   235  // kubernetes object (for example, hits-per-second on an Ingress object).
   236  type ObjectMetricSource struct {
   237  	// target is the described Kubernetes object.
   238  	Target CrossVersionObjectReference `json:"target" protobuf:"bytes,1,name=target"`
   239  
   240  	// metricName is the name of the metric in question.
   241  	MetricName string `json:"metricName" protobuf:"bytes,2,name=metricName"`
   242  
   243  	// targetValue is the target value of the metric (as a quantity).
   244  	TargetValue resource.Quantity `json:"targetValue" protobuf:"bytes,3,name=targetValue"`
   245  
   246  	// selector is the string-encoded form of a standard kubernetes label selector for the given metric.
   247  	// When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping
   248  	// When unset, just the metricName will be used to gather metrics.
   249  	// +optional
   250  	Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,4,name=selector"`
   251  
   252  	// averageValue is the target value of the average of the
   253  	// metric across all relevant pods (as a quantity)
   254  	// +optional
   255  	AverageValue *resource.Quantity `json:"averageValue,omitempty" protobuf:"bytes,5,name=averageValue"`
   256  }
   257  
   258  // PodsMetricSource indicates how to scale on a metric describing each pod in
   259  // the current scale target (for example, transactions-processed-per-second).
   260  // The values will be averaged together before being compared to the target
   261  // value.
   262  type PodsMetricSource struct {
   263  	// metricName is the name of the metric in question
   264  	MetricName string `json:"metricName" protobuf:"bytes,1,name=metricName"`
   265  
   266  	// targetAverageValue is the target value of the average of the
   267  	// metric across all relevant pods (as a quantity)
   268  	TargetAverageValue resource.Quantity `json:"targetAverageValue" protobuf:"bytes,2,name=targetAverageValue"`
   269  
   270  	// selector is the string-encoded form of a standard kubernetes label selector for the given metric
   271  	// When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping
   272  	// When unset, just the metricName will be used to gather metrics.
   273  	// +optional
   274  	Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,3,name=selector"`
   275  }
   276  
   277  // ResourceMetricSource indicates how to scale on a resource metric known to
   278  // Kubernetes, as specified in requests and limits, describing each pod in the
   279  // current scale target (e.g. CPU or memory).  The values will be averaged
   280  // together before being compared to the target.  Such metrics are built in to
   281  // Kubernetes, and have special scaling options on top of those available to
   282  // normal per-pod metrics using the "pods" source.  Only one "target" type
   283  // should be set.
   284  type ResourceMetricSource struct {
   285  	// name is the name of the resource in question.
   286  	Name v1.ResourceName `json:"name" protobuf:"bytes,1,name=name"`
   287  
   288  	// targetAverageUtilization is the target value of the average of the
   289  	// resource metric across all relevant pods, represented as a percentage of
   290  	// the requested value of the resource for the pods.
   291  	// +optional
   292  	TargetAverageUtilization *int32 `json:"targetAverageUtilization,omitempty" protobuf:"varint,2,opt,name=targetAverageUtilization"`
   293  
   294  	// targetAverageValue is the target value of the average of the
   295  	// resource metric across all relevant pods, as a raw value (instead of as
   296  	// a percentage of the request), similar to the "pods" metric source type.
   297  	// +optional
   298  	TargetAverageValue *resource.Quantity `json:"targetAverageValue,omitempty" protobuf:"bytes,3,opt,name=targetAverageValue"`
   299  }
   300  
   301  // ContainerResourceMetricSource indicates how to scale on a resource metric known to
   302  // Kubernetes, as specified in the requests and limits, describing a single container in
   303  // each of the pods of the current scale target(e.g. CPU or memory). The values will be
   304  // averaged together before being compared to the target. Such metrics are built into
   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  	// targetAverageUtilization is the target value of the average of the
   313  	// resource metric across all relevant pods, represented as a percentage of
   314  	// the requested value of the resource for the pods.
   315  	// +optional
   316  	TargetAverageUtilization *int32 `json:"targetAverageUtilization,omitempty" protobuf:"varint,2,opt,name=targetAverageUtilization"`
   317  
   318  	// targetAverageValue is the target value of the average of the
   319  	// resource metric across all relevant pods, as a raw value (instead of as
   320  	// a percentage of the request), similar to the "pods" metric source type.
   321  	// +optional
   322  	TargetAverageValue *resource.Quantity `json:"targetAverageValue,omitempty" protobuf:"bytes,3,opt,name=targetAverageValue"`
   323  
   324  	// container is the name of the container in the pods of the scaling target.
   325  	Container string `json:"container" protobuf:"bytes,5,opt,name=container"`
   326  }
   327  
   328  // ExternalMetricSource indicates how to scale on a metric not associated with
   329  // any Kubernetes object (for example length of queue in cloud
   330  // messaging service, or QPS from loadbalancer running outside of cluster).
   331  type ExternalMetricSource struct {
   332  	// metricName is the name of the metric in question.
   333  	MetricName string `json:"metricName" protobuf:"bytes,1,name=metricName"`
   334  
   335  	// metricSelector is used to identify a specific time series
   336  	// within a given metric.
   337  	// +optional
   338  	MetricSelector *metav1.LabelSelector `json:"metricSelector,omitempty" protobuf:"bytes,2,opt,name=metricSelector"`
   339  
   340  	// targetValue is the target value of the metric (as a quantity).
   341  	// Mutually exclusive with TargetAverageValue.
   342  	// +optional
   343  	TargetValue *resource.Quantity `json:"targetValue,omitempty" protobuf:"bytes,3,opt,name=targetValue"`
   344  
   345  	// targetAverageValue is the target per-pod value of global metric (as a quantity).
   346  	// Mutually exclusive with TargetValue.
   347  	// +optional
   348  	TargetAverageValue *resource.Quantity `json:"targetAverageValue,omitempty" protobuf:"bytes,4,opt,name=targetAverageValue"`
   349  }
   350  
   351  // MetricStatus describes the last-read state of a single metric.
   352  type MetricStatus struct {
   353  	// type is the type of metric source.  It will be one of "ContainerResource",
   354  	// "External", "Object", "Pods" or "Resource", each corresponds to a matching field in the object.
   355  	// Note: "ContainerResource" type is available on when the feature-gate
   356  	// HPAContainerMetrics is enabled
   357  	Type MetricSourceType `json:"type" protobuf:"bytes,1,name=type"`
   358  
   359  	// object refers to a metric describing a single kubernetes object
   360  	// (for example, hits-per-second on an Ingress object).
   361  	// +optional
   362  	Object *ObjectMetricStatus `json:"object,omitempty" protobuf:"bytes,2,opt,name=object"`
   363  
   364  	// pods refers to a metric describing each pod in the current scale target
   365  	// (for example, transactions-processed-per-second).  The values will be
   366  	// averaged together before being compared to the target value.
   367  	// +optional
   368  	Pods *PodsMetricStatus `json:"pods,omitempty" protobuf:"bytes,3,opt,name=pods"`
   369  
   370  	// resource refers to a resource metric (such as those specified in
   371  	// requests and limits) known to Kubernetes describing each pod in the
   372  	// current scale target (e.g. CPU or memory). Such metrics are built in to
   373  	// Kubernetes, and have special scaling options on top of those available
   374  	// to normal per-pod metrics using the "pods" source.
   375  	// +optional
   376  	Resource *ResourceMetricStatus `json:"resource,omitempty" protobuf:"bytes,4,opt,name=resource"`
   377  
   378  	// containerResource refers to a resource metric (such as those specified in
   379  	// requests and limits) known to Kubernetes describing a single container in each pod in the
   380  	// current scale target (e.g. CPU or memory). Such metrics are built in to
   381  	// Kubernetes, and have special scaling options on top of those available
   382  	// to normal per-pod metrics using the "pods" source.
   383  	// +optional
   384  	ContainerResource *ContainerResourceMetricStatus `json:"containerResource,omitempty" protobuf:"bytes,7,opt,name=containerResource"`
   385  
   386  	// external refers to a global metric that is not associated
   387  	// with any Kubernetes object. It allows autoscaling based on information
   388  	// coming from components running outside of cluster
   389  	// (for example length of queue in cloud messaging service, or
   390  	// QPS from loadbalancer running outside of cluster).
   391  	// +optional
   392  	External *ExternalMetricStatus `json:"external,omitempty" protobuf:"bytes,5,opt,name=external"`
   393  }
   394  
   395  // HorizontalPodAutoscalerConditionType are the valid conditions of
   396  // a HorizontalPodAutoscaler.
   397  type HorizontalPodAutoscalerConditionType string
   398  
   399  const (
   400  	// ScalingActive indicates that the HPA controller is able to scale if necessary:
   401  	// it's correctly configured, can fetch the desired metrics, and isn't disabled.
   402  	ScalingActive HorizontalPodAutoscalerConditionType = "ScalingActive"
   403  	// AbleToScale indicates a lack of transient issues which prevent scaling from occurring,
   404  	// such as being in a backoff window, or being unable to access/update the target scale.
   405  	AbleToScale HorizontalPodAutoscalerConditionType = "AbleToScale"
   406  	// ScalingLimited indicates that the calculated scale based on metrics would be above or
   407  	// below the range for the HPA, and has thus been capped.
   408  	ScalingLimited HorizontalPodAutoscalerConditionType = "ScalingLimited"
   409  )
   410  
   411  // HorizontalPodAutoscalerCondition describes the state of
   412  // a HorizontalPodAutoscaler at a certain point.
   413  type HorizontalPodAutoscalerCondition struct {
   414  	// type describes the current condition
   415  	Type HorizontalPodAutoscalerConditionType `json:"type" protobuf:"bytes,1,name=type"`
   416  
   417  	// status is the status of the condition (True, False, Unknown)
   418  	Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,name=status"`
   419  
   420  	// lastTransitionTime is the last time the condition transitioned from
   421  	// one status to another
   422  	// +optional
   423  	LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"`
   424  
   425  	// reason is the reason for the condition's last transition.
   426  	// +optional
   427  	Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
   428  
   429  	// message is a human-readable explanation containing details about
   430  	// the transition
   431  	// +optional
   432  	Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
   433  }
   434  
   435  // ObjectMetricStatus indicates the current value of a metric describing a
   436  // kubernetes object (for example, hits-per-second on an Ingress object).
   437  type ObjectMetricStatus struct {
   438  	// target is the described Kubernetes object.
   439  	Target CrossVersionObjectReference `json:"target" protobuf:"bytes,1,name=target"`
   440  
   441  	// metricName is the name of the metric in question.
   442  	MetricName string `json:"metricName" protobuf:"bytes,2,name=metricName"`
   443  
   444  	// currentValue is the current value of the metric (as a quantity).
   445  	CurrentValue resource.Quantity `json:"currentValue" protobuf:"bytes,3,name=currentValue"`
   446  
   447  	// selector is the string-encoded form of a standard kubernetes label selector for the given metric
   448  	// When set in the ObjectMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping.
   449  	// When unset, just the metricName will be used to gather metrics.
   450  	// +optional
   451  	Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,4,name=selector"`
   452  
   453  	// averageValue is the current value of the average of the
   454  	// metric across all relevant pods (as a quantity)
   455  	// +optional
   456  	AverageValue *resource.Quantity `json:"averageValue,omitempty" protobuf:"bytes,5,name=averageValue"`
   457  }
   458  
   459  // PodsMetricStatus indicates the current value of a metric describing each pod in
   460  // the current scale target (for example, transactions-processed-per-second).
   461  type PodsMetricStatus struct {
   462  	// metricName is the name of the metric in question
   463  	MetricName string `json:"metricName" protobuf:"bytes,1,name=metricName"`
   464  
   465  	// currentAverageValue is the current value of the average of the
   466  	// metric across all relevant pods (as a quantity)
   467  	CurrentAverageValue resource.Quantity `json:"currentAverageValue" protobuf:"bytes,2,name=currentAverageValue"`
   468  
   469  	// selector is the string-encoded form of a standard kubernetes label selector for the given metric
   470  	// When set in the PodsMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping.
   471  	// When unset, just the metricName will be used to gather metrics.
   472  	// +optional
   473  	Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,3,name=selector"`
   474  }
   475  
   476  // ResourceMetricStatus indicates the current value of a resource metric known to
   477  // Kubernetes, as specified in requests and limits, describing each pod in the
   478  // current scale target (e.g. CPU or memory).  Such metrics are built in to
   479  // Kubernetes, and have special scaling options on top of those available to
   480  // normal per-pod metrics using the "pods" source.
   481  type ResourceMetricStatus struct {
   482  	// name is the name of the resource in question.
   483  	Name v1.ResourceName `json:"name" protobuf:"bytes,1,name=name"`
   484  
   485  	// currentAverageUtilization is the current value of the average of the
   486  	// resource metric across all relevant pods, represented as a percentage of
   487  	// the requested value of the resource for the pods.  It will only be
   488  	// present if `targetAverageValue` was set in the corresponding metric
   489  	// specification.
   490  	// +optional
   491  	CurrentAverageUtilization *int32 `json:"currentAverageUtilization,omitempty" protobuf:"bytes,2,opt,name=currentAverageUtilization"`
   492  
   493  	// currentAverageValue is the current value of the average of the
   494  	// resource metric across all relevant pods, as a raw value (instead of as
   495  	// a percentage of the request), similar to the "pods" metric source type.
   496  	// It will always be set, regardless of the corresponding metric specification.
   497  	CurrentAverageValue resource.Quantity `json:"currentAverageValue" protobuf:"bytes,3,name=currentAverageValue"`
   498  }
   499  
   500  // ContainerResourceMetricStatus indicates the current value of a resource metric known to
   501  // Kubernetes, as specified in requests and limits, describing a single container in each pod in the
   502  // current scale target (e.g. CPU or memory).  Such metrics are built in to
   503  // Kubernetes, and have special scaling options on top of those available to
   504  // normal per-pod metrics using the "pods" source.
   505  type ContainerResourceMetricStatus struct {
   506  	// name is the name of the resource in question.
   507  	Name v1.ResourceName `json:"name" protobuf:"bytes,1,name=name"`
   508  
   509  	// currentAverageUtilization is the current value of the average of the
   510  	// resource metric across all relevant pods, represented as a percentage of
   511  	// the requested value of the resource for the pods.  It will only be
   512  	// present if `targetAverageValue` was set in the corresponding metric
   513  	// specification.
   514  	// +optional
   515  	CurrentAverageUtilization *int32 `json:"currentAverageUtilization,omitempty" protobuf:"bytes,2,opt,name=currentAverageUtilization"`
   516  
   517  	// currentAverageValue is the current value of the average of the
   518  	// resource metric across all relevant pods, as a raw value (instead of as
   519  	// a percentage of the request), similar to the "pods" metric source type.
   520  	// It will always be set, regardless of the corresponding metric specification.
   521  	CurrentAverageValue resource.Quantity `json:"currentAverageValue" protobuf:"bytes,3,name=currentAverageValue"`
   522  
   523  	// container is the name of the container in the pods of the scaling taget
   524  	Container string `json:"container" protobuf:"bytes,4,opt,name=container"`
   525  }
   526  
   527  // ExternalMetricStatus indicates the current value of a global metric
   528  // not associated with any Kubernetes object.
   529  type ExternalMetricStatus struct {
   530  	// metricName is the name of a metric used for autoscaling in
   531  	// metric system.
   532  	MetricName string `json:"metricName" protobuf:"bytes,1,name=metricName"`
   533  
   534  	// metricSelector is used to identify a specific time series
   535  	// within a given metric.
   536  	// +optional
   537  	MetricSelector *metav1.LabelSelector `json:"metricSelector,omitempty" protobuf:"bytes,2,opt,name=metricSelector"`
   538  	// currentValue is the current value of the metric (as a quantity)
   539  	CurrentValue resource.Quantity `json:"currentValue" protobuf:"bytes,3,name=currentValue"`
   540  
   541  	// currentAverageValue is the current value of metric averaged over autoscaled pods.
   542  	// +optional
   543  	CurrentAverageValue *resource.Quantity `json:"currentAverageValue,omitempty" protobuf:"bytes,4,opt,name=currentAverageValue"`
   544  }
   545  

View as plain text