mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
Add external metric type to HPA API
This commit is contained in:
parent
c7414323d8
commit
8a002d855f
@ -111,6 +111,12 @@ var (
|
|||||||
// Kubernetes, and have special scaling options on top of those available
|
// Kubernetes, and have special scaling options on top of those available
|
||||||
// to normal per-pod metrics (the "pods" source).
|
// to normal per-pod metrics (the "pods" source).
|
||||||
ResourceMetricSourceType MetricSourceType = "Resource"
|
ResourceMetricSourceType MetricSourceType = "Resource"
|
||||||
|
// ExternalMetricSourceType is a global metric that is not associated
|
||||||
|
// with any Kubernetes object. It allows autoscaling based on information
|
||||||
|
// coming from components running outside of cluster
|
||||||
|
// (for example length of queue in cloud messaging service, or
|
||||||
|
// QPS from loadbalancer running outside of cluster).
|
||||||
|
ExternalMetricSourceType MetricSourceType = "External"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MetricSpec specifies how to scale based on a single metric
|
// MetricSpec specifies how to scale based on a single metric
|
||||||
@ -136,6 +142,13 @@ type MetricSpec struct {
|
|||||||
// to normal per-pod metrics using the "pods" source.
|
// to normal per-pod metrics using the "pods" source.
|
||||||
// +optional
|
// +optional
|
||||||
Resource *ResourceMetricSource
|
Resource *ResourceMetricSource
|
||||||
|
// External refers to a global metric that is not associated
|
||||||
|
// with any Kubernetes object. It allows autoscaling based on information
|
||||||
|
// coming from components running outside of cluster
|
||||||
|
// (for example length of queue in cloud messaging service, or
|
||||||
|
// QPS from loadbalancer running outside of cluster).
|
||||||
|
// +optional
|
||||||
|
External *ExternalMetricSource
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectMetricSource indicates how to scale on a metric describing a
|
// ObjectMetricSource indicates how to scale on a metric describing a
|
||||||
@ -184,6 +197,26 @@ type ResourceMetricSource struct {
|
|||||||
TargetAverageValue *resource.Quantity
|
TargetAverageValue *resource.Quantity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExternalMetricSource indicates how to scale on a metric not associated with
|
||||||
|
// any Kubernetes object (for example length of queue in cloud
|
||||||
|
// messaging service, or QPS from loadbalancer running outside of cluster).
|
||||||
|
type ExternalMetricSource struct {
|
||||||
|
// metricName is the name of the metric in question.
|
||||||
|
MetricName string
|
||||||
|
// MetricSelector is used to identify a specific time series
|
||||||
|
// within a given metric.
|
||||||
|
// +optional
|
||||||
|
MetricSelector *metav1.LabelSelector
|
||||||
|
// TargetValue is the target value of the metric (as a quantity).
|
||||||
|
// Mutually exclusive with TargetAverageValue.
|
||||||
|
// +optional
|
||||||
|
TargetValue *resource.Quantity
|
||||||
|
// TargetAverageValue is the target per-pod value of global metric (as a quantity).
|
||||||
|
// Mutually exclusive with TargetValue.
|
||||||
|
// +optional
|
||||||
|
TargetAverageValue *resource.Quantity
|
||||||
|
}
|
||||||
|
|
||||||
// HorizontalPodAutoscalerStatus describes the current status of a horizontal pod autoscaler.
|
// HorizontalPodAutoscalerStatus describes the current status of a horizontal pod autoscaler.
|
||||||
type HorizontalPodAutoscalerStatus struct {
|
type HorizontalPodAutoscalerStatus struct {
|
||||||
// ObservedGeneration is the most recent generation observed by this autoscaler.
|
// ObservedGeneration is the most recent generation observed by this autoscaler.
|
||||||
@ -282,6 +315,13 @@ type MetricStatus struct {
|
|||||||
// to normal per-pod metrics using the "pods" source.
|
// to normal per-pod metrics using the "pods" source.
|
||||||
// +optional
|
// +optional
|
||||||
Resource *ResourceMetricStatus
|
Resource *ResourceMetricStatus
|
||||||
|
// External refers to a global metric that is not associated
|
||||||
|
// with any Kubernetes object. It allows autoscaling based on information
|
||||||
|
// coming from components running outside of cluster
|
||||||
|
// (for example length of queue in cloud messaging service, or
|
||||||
|
// QPS from loadbalancer running outside of cluster).
|
||||||
|
// +optional
|
||||||
|
External *ExternalMetricStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectMetricStatus indicates the current value of a metric describing a
|
// ObjectMetricStatus indicates the current value of a metric describing a
|
||||||
@ -328,6 +368,23 @@ type ResourceMetricStatus struct {
|
|||||||
CurrentAverageValue resource.Quantity
|
CurrentAverageValue resource.Quantity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExternalMetricStatus indicates the current value of a global metric
|
||||||
|
// not associated with any Kubernetes object.
|
||||||
|
type ExternalMetricStatus struct {
|
||||||
|
// MetricName is the name of a metric used for autoscaling in
|
||||||
|
// metric system.
|
||||||
|
MetricName string
|
||||||
|
// MetricSelector is used to identify a specific time series
|
||||||
|
// within a given metric.
|
||||||
|
// +optional
|
||||||
|
MetricSelector *metav1.LabelSelector
|
||||||
|
// CurrentValue is the current value of the metric (as a quantity)
|
||||||
|
CurrentValue resource.Quantity
|
||||||
|
// CurrentAverageValue is the current value of metric averaged over autoscaled pods.
|
||||||
|
// +optional
|
||||||
|
CurrentAverageValue *resource.Quantity
|
||||||
|
}
|
||||||
|
|
||||||
// +genclient
|
// +genclient
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
|
|
||||||
|
@ -161,6 +161,12 @@ var (
|
|||||||
// Kubernetes, and have special scaling options on top of those available
|
// Kubernetes, and have special scaling options on top of those available
|
||||||
// to normal per-pod metrics (the "pods" source).
|
// to normal per-pod metrics (the "pods" source).
|
||||||
ResourceMetricSourceType MetricSourceType = "Resource"
|
ResourceMetricSourceType MetricSourceType = "Resource"
|
||||||
|
// ExternalMetricSourceType is a global metric that is not associated
|
||||||
|
// with any Kubernetes object. It allows autoscaling based on information
|
||||||
|
// coming from components running outside of cluster
|
||||||
|
// (for example length of queue in cloud messaging service, or
|
||||||
|
// QPS from loadbalancer running outside of cluster).
|
||||||
|
ExternalMetricSourceType MetricSourceType = "External"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MetricSpec specifies how to scale based on a single metric
|
// MetricSpec specifies how to scale based on a single metric
|
||||||
@ -186,6 +192,13 @@ type MetricSpec struct {
|
|||||||
// to normal per-pod metrics using the "pods" source.
|
// to normal per-pod metrics using the "pods" source.
|
||||||
// +optional
|
// +optional
|
||||||
Resource *ResourceMetricSource `json:"resource,omitempty" protobuf:"bytes,4,opt,name=resource"`
|
Resource *ResourceMetricSource `json:"resource,omitempty" protobuf:"bytes,4,opt,name=resource"`
|
||||||
|
// external refers to a global metric that is not associated
|
||||||
|
// with any Kubernetes object. It allows autoscaling based on information
|
||||||
|
// coming from components running outside of cluster
|
||||||
|
// (for example length of queue in cloud messaging service, or
|
||||||
|
// QPS from loadbalancer running outside of cluster).
|
||||||
|
// +optional
|
||||||
|
External *ExternalMetricSource `json:"external,omitempty" protobuf:"bytes,5,opt,name=external"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectMetricSource indicates how to scale on a metric describing a
|
// ObjectMetricSource indicates how to scale on a metric describing a
|
||||||
@ -234,6 +247,26 @@ type ResourceMetricSource struct {
|
|||||||
TargetAverageValue *resource.Quantity `json:"targetAverageValue,omitempty" protobuf:"bytes,3,opt,name=targetAverageValue"`
|
TargetAverageValue *resource.Quantity `json:"targetAverageValue,omitempty" protobuf:"bytes,3,opt,name=targetAverageValue"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExternalMetricSource indicates how to scale on a metric not associated with
|
||||||
|
// any Kubernetes object (for example length of queue in cloud
|
||||||
|
// messaging service, or QPS from loadbalancer running outside of cluster).
|
||||||
|
type ExternalMetricSource struct {
|
||||||
|
// metricName is the name of the metric in question.
|
||||||
|
MetricName string `json:"metricName" protobuf:"bytes,1,name=metricName"`
|
||||||
|
// metricSelector is used to identify a specific time series
|
||||||
|
// within a given metric.
|
||||||
|
// +optional
|
||||||
|
MetricSelector *metav1.LabelSelector `json:"metricSelector,omitempty" protobuf:"bytes,2,opt,name=metricSelector"`
|
||||||
|
// targetValue is the target value of the metric (as a quantity).
|
||||||
|
// Mutually exclusive with TargetAverageValue.
|
||||||
|
// +optional
|
||||||
|
TargetValue *resource.Quantity `json:"targetValue,omitempty" protobuf:"bytes,3,opt,name=targetValue"`
|
||||||
|
// targetAverageValue is the target per-pod value of global metric (as a quantity).
|
||||||
|
// Mutually exclusive with TargetValue.
|
||||||
|
// +optional
|
||||||
|
TargetAverageValue *resource.Quantity `json:"targetAverageValue,omitempty" protobuf:"bytes,4,opt,name=targetAverageValue"`
|
||||||
|
}
|
||||||
|
|
||||||
// MetricStatus describes the last-read state of a single metric.
|
// MetricStatus describes the last-read state of a single metric.
|
||||||
type MetricStatus struct {
|
type MetricStatus struct {
|
||||||
// type is the type of metric source. It will be one of "Object",
|
// type is the type of metric source. It will be one of "Object",
|
||||||
@ -256,6 +289,13 @@ type MetricStatus struct {
|
|||||||
// to normal per-pod metrics using the "pods" source.
|
// to normal per-pod metrics using the "pods" source.
|
||||||
// +optional
|
// +optional
|
||||||
Resource *ResourceMetricStatus `json:"resource,omitempty" protobuf:"bytes,4,opt,name=resource"`
|
Resource *ResourceMetricStatus `json:"resource,omitempty" protobuf:"bytes,4,opt,name=resource"`
|
||||||
|
// external refers to a global metric that is not associated
|
||||||
|
// with any Kubernetes object. It allows autoscaling based on information
|
||||||
|
// coming from components running outside of cluster
|
||||||
|
// (for example length of queue in cloud messaging service, or
|
||||||
|
// QPS from loadbalancer running outside of cluster).
|
||||||
|
// +optional
|
||||||
|
External *ExternalMetricStatus `json:"external,omitempty" protobuf:"bytes,5,opt,name=external"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// HorizontalPodAutoscalerConditionType are the valid conditions of
|
// HorizontalPodAutoscalerConditionType are the valid conditions of
|
||||||
@ -337,3 +377,20 @@ type ResourceMetricStatus struct {
|
|||||||
// It will always be set, regardless of the corresponding metric specification.
|
// It will always be set, regardless of the corresponding metric specification.
|
||||||
CurrentAverageValue resource.Quantity `json:"currentAverageValue" protobuf:"bytes,3,name=currentAverageValue"`
|
CurrentAverageValue resource.Quantity `json:"currentAverageValue" protobuf:"bytes,3,name=currentAverageValue"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExternalMetricStatus indicates the current value of a global metric
|
||||||
|
// not associated with any Kubernetes object.
|
||||||
|
type ExternalMetricStatus struct {
|
||||||
|
// metricName is the name of a metric used for autoscaling in
|
||||||
|
// metric system.
|
||||||
|
MetricName string `json:"metricName" protobuf:"bytes,1,name=metricName"`
|
||||||
|
// metricSelector is used to identify a specific time series
|
||||||
|
// within a given metric.
|
||||||
|
// +optional
|
||||||
|
MetricSelector *metav1.LabelSelector `json:"metricSelector,omitempty" protobuf:"bytes,2,opt,name=metricSelector"`
|
||||||
|
// currentValue is the current value of the metric (as a quantity)
|
||||||
|
CurrentValue resource.Quantity `json:"currentValue" protobuf:"bytes,3,name=currentValue"`
|
||||||
|
// currentAverageValue is the current value of metric averaged over autoscaled pods.
|
||||||
|
// +optional
|
||||||
|
CurrentAverageValue *resource.Quantity `json:"currentAverageValue,omitempty" protobuf:"bytes,4,opt,name=currentAverageValue"`
|
||||||
|
}
|
||||||
|
@ -73,6 +73,12 @@ var (
|
|||||||
// Kubernetes, and have special scaling options on top of those available
|
// Kubernetes, and have special scaling options on top of those available
|
||||||
// to normal per-pod metrics (the "pods" source).
|
// to normal per-pod metrics (the "pods" source).
|
||||||
ResourceMetricSourceType MetricSourceType = "Resource"
|
ResourceMetricSourceType MetricSourceType = "Resource"
|
||||||
|
// ExternalMetricSourceType is a global metric that is not associated
|
||||||
|
// with any Kubernetes object. It allows autoscaling based on information
|
||||||
|
// coming from components running outside of cluster
|
||||||
|
// (for example length of queue in cloud messaging service, or
|
||||||
|
// QPS from loadbalancer running outside of cluster).
|
||||||
|
ExternalMetricSourceType MetricSourceType = "External"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MetricSpec specifies how to scale based on a single metric
|
// MetricSpec specifies how to scale based on a single metric
|
||||||
@ -98,6 +104,13 @@ type MetricSpec struct {
|
|||||||
// to normal per-pod metrics using the "pods" source.
|
// to normal per-pod metrics using the "pods" source.
|
||||||
// +optional
|
// +optional
|
||||||
Resource *ResourceMetricSource `json:"resource,omitempty" protobuf:"bytes,4,opt,name=resource"`
|
Resource *ResourceMetricSource `json:"resource,omitempty" protobuf:"bytes,4,opt,name=resource"`
|
||||||
|
// external refers to a global metric that is not associated
|
||||||
|
// with any Kubernetes object. It allows autoscaling based on information
|
||||||
|
// coming from components running outside of cluster
|
||||||
|
// (for example length of queue in cloud messaging service, or
|
||||||
|
// QPS from loadbalancer running outside of cluster).
|
||||||
|
// +optional
|
||||||
|
External *ExternalMetricSource `json:"external,omitempty" protobuf:"bytes,5,opt,name=external"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectMetricSource indicates how to scale on a metric describing a
|
// ObjectMetricSource indicates how to scale on a metric describing a
|
||||||
@ -146,6 +159,27 @@ type ResourceMetricSource struct {
|
|||||||
TargetAverageValue *resource.Quantity `json:"targetAverageValue,omitempty" protobuf:"bytes,3,opt,name=targetAverageValue"`
|
TargetAverageValue *resource.Quantity `json:"targetAverageValue,omitempty" protobuf:"bytes,3,opt,name=targetAverageValue"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExternalMetricSource indicates how to scale on a metric not associated with
|
||||||
|
// any Kubernetes object (for example length of queue in cloud
|
||||||
|
// messaging service, or QPS from loadbalancer running outside of cluster).
|
||||||
|
// Exactly one "target" type should be set.
|
||||||
|
type ExternalMetricSource struct {
|
||||||
|
// metricName is the name of the metric in question.
|
||||||
|
MetricName string `json:"metricName" protobuf:"bytes,1,name=metricName"`
|
||||||
|
// metricSelector is used to identify a specific time series
|
||||||
|
// within a given metric.
|
||||||
|
// +optional
|
||||||
|
MetricSelector *metav1.LabelSelector `json:"metricSelector,omitempty" protobuf:"bytes,2,opt,name=metricSelector"`
|
||||||
|
// targetValue is the target value of the metric (as a quantity).
|
||||||
|
// Mutually exclusive with TargetAverageValue.
|
||||||
|
// +optional
|
||||||
|
TargetValue *resource.Quantity `json:"targetValue,omitempty" protobuf:"bytes,3,opt,name=targetValue"`
|
||||||
|
// targetAverageValue is the target per-pod value of global metric (as a quantity).
|
||||||
|
// Mutually exclusive with TargetValue.
|
||||||
|
// +optional
|
||||||
|
TargetAverageValue *resource.Quantity `json:"targetAverageValue,omitempty" protobuf:"bytes,4,opt,name=targetAverageValue"`
|
||||||
|
}
|
||||||
|
|
||||||
// HorizontalPodAutoscalerStatus describes the current status of a horizontal pod autoscaler.
|
// HorizontalPodAutoscalerStatus describes the current status of a horizontal pod autoscaler.
|
||||||
type HorizontalPodAutoscalerStatus struct {
|
type HorizontalPodAutoscalerStatus struct {
|
||||||
// observedGeneration is the most recent generation observed by this autoscaler.
|
// observedGeneration is the most recent generation observed by this autoscaler.
|
||||||
@ -231,6 +265,13 @@ type MetricStatus struct {
|
|||||||
// to normal per-pod metrics using the "pods" source.
|
// to normal per-pod metrics using the "pods" source.
|
||||||
// +optional
|
// +optional
|
||||||
Resource *ResourceMetricStatus `json:"resource,omitempty" protobuf:"bytes,4,opt,name=resource"`
|
Resource *ResourceMetricStatus `json:"resource,omitempty" protobuf:"bytes,4,opt,name=resource"`
|
||||||
|
// external refers to a global metric that is not associated
|
||||||
|
// with any Kubernetes object. It allows autoscaling based on information
|
||||||
|
// coming from components running outside of cluster
|
||||||
|
// (for example length of queue in cloud messaging service, or
|
||||||
|
// QPS from loadbalancer running outside of cluster).
|
||||||
|
// +optional
|
||||||
|
External *ExternalMetricStatus `json:"external,omitempty" protobuf:"bytes,5,opt,name=external"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectMetricStatus indicates the current value of a metric describing a
|
// ObjectMetricStatus indicates the current value of a metric describing a
|
||||||
@ -277,6 +318,23 @@ type ResourceMetricStatus struct {
|
|||||||
CurrentAverageValue resource.Quantity `json:"currentAverageValue" protobuf:"bytes,3,name=currentAverageValue"`
|
CurrentAverageValue resource.Quantity `json:"currentAverageValue" protobuf:"bytes,3,name=currentAverageValue"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExternalMetricStatus indicates the current value of a global metric
|
||||||
|
// not associated with any Kubernetes object.
|
||||||
|
type ExternalMetricStatus struct {
|
||||||
|
// metricName is the name of a metric used for autoscaling in
|
||||||
|
// metric system.
|
||||||
|
MetricName string `json:"metricName" protobuf:"bytes,1,name=metricName"`
|
||||||
|
// metricSelector is used to identify a specific time series
|
||||||
|
// within a given metric.
|
||||||
|
// +optional
|
||||||
|
MetricSelector *metav1.LabelSelector `json:"metricSelector,omitempty" protobuf:"bytes,2,opt,name=metricSelector"`
|
||||||
|
// currentValue is the current value of the metric (as a quantity)
|
||||||
|
CurrentValue resource.Quantity `json:"currentValue" protobuf:"bytes,3,name=currentValue"`
|
||||||
|
// currentAverageValue is the current value of metric averaged over autoscaled pods.
|
||||||
|
// +optional
|
||||||
|
CurrentAverageValue *resource.Quantity `json:"currentAverageValue,omitempty" protobuf:"bytes,4,opt,name=currentAverageValue"`
|
||||||
|
}
|
||||||
|
|
||||||
// +genclient
|
// +genclient
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user