mirror of https://github.com/k3s-io/k3s
Merge pull request #12659 from mwielgus/horizontal_status
HorizontalPodAutoscaler statuspull/6/head
commit
8d74f610f7
|
@ -104,6 +104,9 @@ func deepCopy_expapi_HorizontalPodAutoscaler(in HorizontalPodAutoscaler, out *Ho
|
|||
if err := deepCopy_expapi_HorizontalPodAutoscalerSpec(in.Spec, &out.Spec, c); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := deepCopy_expapi_HorizontalPodAutoscalerStatus(in.Status, &out.Status, c); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -138,12 +141,29 @@ func deepCopy_expapi_HorizontalPodAutoscalerSpec(in HorizontalPodAutoscalerSpec,
|
|||
}
|
||||
out.MinCount = in.MinCount
|
||||
out.MaxCount = in.MaxCount
|
||||
if err := deepCopy_expapi_TargetConsumption(in.Target, &out.Target, c); err != nil {
|
||||
if err := deepCopy_expapi_ResourceConsumption(in.Target, &out.Target, c); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func deepCopy_expapi_HorizontalPodAutoscalerStatus(in HorizontalPodAutoscalerStatus, out *HorizontalPodAutoscalerStatus, c *conversion.Cloner) error {
|
||||
out.CurrentReplicas = in.CurrentReplicas
|
||||
out.DesiredReplicas = in.DesiredReplicas
|
||||
if err := deepCopy_expapi_ResourceConsumption(in.CurrentConsumption, &out.CurrentConsumption, c); err != nil {
|
||||
return err
|
||||
}
|
||||
if in.LastScaleTimestamp != nil {
|
||||
out.LastScaleTimestamp = new(util.Time)
|
||||
if err := deepCopy_util_Time(*in.LastScaleTimestamp, out.LastScaleTimestamp, c); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.LastScaleTimestamp = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func deepCopy_expapi_ReplicationControllerDummy(in ReplicationControllerDummy, out *ReplicationControllerDummy, c *conversion.Cloner) error {
|
||||
if err := deepCopy_api_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
|
||||
return err
|
||||
|
@ -151,6 +171,14 @@ func deepCopy_expapi_ReplicationControllerDummy(in ReplicationControllerDummy, o
|
|||
return nil
|
||||
}
|
||||
|
||||
func deepCopy_expapi_ResourceConsumption(in ResourceConsumption, out *ResourceConsumption, c *conversion.Cloner) error {
|
||||
out.Resource = in.Resource
|
||||
if err := deepCopy_resource_Quantity(in.Quantity, &out.Quantity, c); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func deepCopy_expapi_Scale(in Scale, out *Scale, c *conversion.Cloner) error {
|
||||
if err := deepCopy_api_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
|
||||
return err
|
||||
|
@ -194,14 +222,6 @@ func deepCopy_expapi_SubresourceReference(in SubresourceReference, out *Subresou
|
|||
return nil
|
||||
}
|
||||
|
||||
func deepCopy_expapi_TargetConsumption(in TargetConsumption, out *TargetConsumption, c *conversion.Cloner) error {
|
||||
out.Resource = in.Resource
|
||||
if err := deepCopy_resource_Quantity(in.Quantity, &out.Quantity, c); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func deepCopy_util_Time(in util.Time, out *util.Time, c *conversion.Cloner) error {
|
||||
if newVal, err := c.DeepCopy(in.Time); err != nil {
|
||||
return err
|
||||
|
@ -220,12 +240,13 @@ func init() {
|
|||
deepCopy_expapi_HorizontalPodAutoscaler,
|
||||
deepCopy_expapi_HorizontalPodAutoscalerList,
|
||||
deepCopy_expapi_HorizontalPodAutoscalerSpec,
|
||||
deepCopy_expapi_HorizontalPodAutoscalerStatus,
|
||||
deepCopy_expapi_ReplicationControllerDummy,
|
||||
deepCopy_expapi_ResourceConsumption,
|
||||
deepCopy_expapi_Scale,
|
||||
deepCopy_expapi_ScaleSpec,
|
||||
deepCopy_expapi_ScaleStatus,
|
||||
deepCopy_expapi_SubresourceReference,
|
||||
deepCopy_expapi_TargetConsumption,
|
||||
deepCopy_util_Time,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
@ -31,6 +31,7 @@ package expapi
|
|||
import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/resource"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
)
|
||||
|
||||
// ScaleSpec describes the attributes a Scale subresource
|
||||
|
@ -74,8 +75,8 @@ type SubresourceReference struct {
|
|||
Subresource string `json:"subresource,omitempty"`
|
||||
}
|
||||
|
||||
// TargetConsumption is an object for specifying target average resource consumption of a particular resource.
|
||||
type TargetConsumption struct {
|
||||
// ResourceConsumption is an object for specifying average resource consumption of a particular resource.
|
||||
type ResourceConsumption struct {
|
||||
Resource api.ResourceName `json:"resource,omitempty"`
|
||||
Quantity resource.Quantity `json:"quantity,omitempty"`
|
||||
}
|
||||
|
@ -91,7 +92,27 @@ type HorizontalPodAutoscalerSpec struct {
|
|||
MaxCount int `json:"maxCount"`
|
||||
// Target is the target average consumption of the given resource that the autoscaler will try to maintain by adjusting the desired number of pods.
|
||||
// Currently two types of resources are supported: "cpu" and "memory".
|
||||
Target TargetConsumption `json:"target"`
|
||||
Target ResourceConsumption `json:"target"`
|
||||
}
|
||||
|
||||
// HorizontalPodAutoscalerStatus contains the current status of a horizontal pod autoscaler
|
||||
type HorizontalPodAutoscalerStatus struct {
|
||||
// CurrentReplicas is the number of replicas of pods managed by this autoscaler.
|
||||
CurrentReplicas int `json:"replicas"`
|
||||
|
||||
// DesiredReplicas is the desired number of replicas of pods managed by this autoscaler.
|
||||
// The number may be different because pod downscaling is someteimes delayed to keep the number
|
||||
// of pods stable.
|
||||
DesiredReplicas int `json:"replicas"`
|
||||
|
||||
// CurrentConsumption is the current average consumption of the given resource that the autoscaler will
|
||||
// try to maintain by adjusting the desired number of pods.
|
||||
// Two types of resources are supported: "cpu" and "memory".
|
||||
CurrentConsumption ResourceConsumption `json:"currentConsumption"`
|
||||
|
||||
// LastScaleTimestamp is the last time the HorizontalPodAutoscaler scaled the number of pods.
|
||||
// This is used by the autoscaler to controll how often the number of pods is changed.
|
||||
LastScaleTimestamp *util.Time `json:"lastScaleTimestamp,omitempty"`
|
||||
}
|
||||
|
||||
// HorizontalPodAutoscaler represents the configuration of a horizontal pod autoscaler.
|
||||
|
@ -101,6 +122,9 @@ type HorizontalPodAutoscaler struct {
|
|||
|
||||
// Spec defines the behaviour of autoscaler.
|
||||
Spec HorizontalPodAutoscalerSpec `json:"spec,omitempty"`
|
||||
|
||||
// Status represents the current information about the autoscaler.
|
||||
Status HorizontalPodAutoscalerStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// HorizontalPodAutoscaler is a collection of pod autoscalers.
|
||||
|
|
|
@ -156,6 +156,9 @@ func convert_expapi_HorizontalPodAutoscaler_To_v1_HorizontalPodAutoscaler(in *ex
|
|||
if err := convert_expapi_HorizontalPodAutoscalerSpec_To_v1_HorizontalPodAutoscalerSpec(&in.Spec, &out.Spec, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := convert_expapi_HorizontalPodAutoscalerStatus_To_v1_HorizontalPodAutoscalerStatus(&in.Status, &out.Status, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -196,12 +199,31 @@ func convert_expapi_HorizontalPodAutoscalerSpec_To_v1_HorizontalPodAutoscalerSpe
|
|||
}
|
||||
out.MinCount = in.MinCount
|
||||
out.MaxCount = in.MaxCount
|
||||
if err := convert_expapi_TargetConsumption_To_v1_TargetConsumption(&in.Target, &out.Target, s); err != nil {
|
||||
if err := convert_expapi_ResourceConsumption_To_v1_ResourceConsumption(&in.Target, &out.Target, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_expapi_HorizontalPodAutoscalerStatus_To_v1_HorizontalPodAutoscalerStatus(in *expapi.HorizontalPodAutoscalerStatus, out *HorizontalPodAutoscalerStatus, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*expapi.HorizontalPodAutoscalerStatus))(in)
|
||||
}
|
||||
out.CurrentReplicas = in.CurrentReplicas
|
||||
out.DesiredReplicas = in.DesiredReplicas
|
||||
if err := convert_expapi_ResourceConsumption_To_v1_ResourceConsumption(&in.CurrentConsumption, &out.CurrentConsumption, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if in.LastScaleTimestamp != nil {
|
||||
if err := s.Convert(&in.LastScaleTimestamp, &out.LastScaleTimestamp, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.LastScaleTimestamp = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_expapi_ReplicationControllerDummy_To_v1_ReplicationControllerDummy(in *expapi.ReplicationControllerDummy, out *ReplicationControllerDummy, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*expapi.ReplicationControllerDummy))(in)
|
||||
|
@ -212,6 +234,17 @@ func convert_expapi_ReplicationControllerDummy_To_v1_ReplicationControllerDummy(
|
|||
return nil
|
||||
}
|
||||
|
||||
func convert_expapi_ResourceConsumption_To_v1_ResourceConsumption(in *expapi.ResourceConsumption, out *ResourceConsumption, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*expapi.ResourceConsumption))(in)
|
||||
}
|
||||
out.Resource = v1.ResourceName(in.Resource)
|
||||
if err := s.Convert(&in.Quantity, &out.Quantity, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_expapi_Scale_To_v1_Scale(in *expapi.Scale, out *Scale, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*expapi.Scale))(in)
|
||||
|
@ -267,17 +300,6 @@ func convert_expapi_SubresourceReference_To_v1_SubresourceReference(in *expapi.S
|
|||
return nil
|
||||
}
|
||||
|
||||
func convert_expapi_TargetConsumption_To_v1_TargetConsumption(in *expapi.TargetConsumption, out *TargetConsumption, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*expapi.TargetConsumption))(in)
|
||||
}
|
||||
out.Resource = v1.ResourceName(in.Resource)
|
||||
if err := s.Convert(&in.Quantity, &out.Quantity, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1_HorizontalPodAutoscaler_To_expapi_HorizontalPodAutoscaler(in *HorizontalPodAutoscaler, out *expapi.HorizontalPodAutoscaler, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*HorizontalPodAutoscaler))(in)
|
||||
|
@ -291,6 +313,9 @@ func convert_v1_HorizontalPodAutoscaler_To_expapi_HorizontalPodAutoscaler(in *Ho
|
|||
if err := convert_v1_HorizontalPodAutoscalerSpec_To_expapi_HorizontalPodAutoscalerSpec(&in.Spec, &out.Spec, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := convert_v1_HorizontalPodAutoscalerStatus_To_expapi_HorizontalPodAutoscalerStatus(&in.Status, &out.Status, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -331,12 +356,31 @@ func convert_v1_HorizontalPodAutoscalerSpec_To_expapi_HorizontalPodAutoscalerSpe
|
|||
}
|
||||
out.MinCount = in.MinCount
|
||||
out.MaxCount = in.MaxCount
|
||||
if err := convert_v1_TargetConsumption_To_expapi_TargetConsumption(&in.Target, &out.Target, s); err != nil {
|
||||
if err := convert_v1_ResourceConsumption_To_expapi_ResourceConsumption(&in.Target, &out.Target, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1_HorizontalPodAutoscalerStatus_To_expapi_HorizontalPodAutoscalerStatus(in *HorizontalPodAutoscalerStatus, out *expapi.HorizontalPodAutoscalerStatus, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*HorizontalPodAutoscalerStatus))(in)
|
||||
}
|
||||
out.CurrentReplicas = in.CurrentReplicas
|
||||
out.DesiredReplicas = in.DesiredReplicas
|
||||
if err := convert_v1_ResourceConsumption_To_expapi_ResourceConsumption(&in.CurrentConsumption, &out.CurrentConsumption, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if in.LastScaleTimestamp != nil {
|
||||
if err := s.Convert(&in.LastScaleTimestamp, &out.LastScaleTimestamp, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.LastScaleTimestamp = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1_ReplicationControllerDummy_To_expapi_ReplicationControllerDummy(in *ReplicationControllerDummy, out *expapi.ReplicationControllerDummy, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*ReplicationControllerDummy))(in)
|
||||
|
@ -347,6 +391,17 @@ func convert_v1_ReplicationControllerDummy_To_expapi_ReplicationControllerDummy(
|
|||
return nil
|
||||
}
|
||||
|
||||
func convert_v1_ResourceConsumption_To_expapi_ResourceConsumption(in *ResourceConsumption, out *expapi.ResourceConsumption, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*ResourceConsumption))(in)
|
||||
}
|
||||
out.Resource = api.ResourceName(in.Resource)
|
||||
if err := s.Convert(&in.Quantity, &out.Quantity, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1_Scale_To_expapi_Scale(in *Scale, out *expapi.Scale, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*Scale))(in)
|
||||
|
@ -402,17 +457,6 @@ func convert_v1_SubresourceReference_To_expapi_SubresourceReference(in *Subresou
|
|||
return nil
|
||||
}
|
||||
|
||||
func convert_v1_TargetConsumption_To_expapi_TargetConsumption(in *TargetConsumption, out *expapi.TargetConsumption, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*TargetConsumption))(in)
|
||||
}
|
||||
out.Resource = api.ResourceName(in.Resource)
|
||||
if err := s.Convert(&in.Quantity, &out.Quantity, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
err := api.Scheme.AddGeneratedConversionFuncs(
|
||||
convert_api_ListMeta_To_v1_ListMeta,
|
||||
|
@ -420,24 +464,26 @@ func init() {
|
|||
convert_api_TypeMeta_To_v1_TypeMeta,
|
||||
convert_expapi_HorizontalPodAutoscalerList_To_v1_HorizontalPodAutoscalerList,
|
||||
convert_expapi_HorizontalPodAutoscalerSpec_To_v1_HorizontalPodAutoscalerSpec,
|
||||
convert_expapi_HorizontalPodAutoscalerStatus_To_v1_HorizontalPodAutoscalerStatus,
|
||||
convert_expapi_HorizontalPodAutoscaler_To_v1_HorizontalPodAutoscaler,
|
||||
convert_expapi_ReplicationControllerDummy_To_v1_ReplicationControllerDummy,
|
||||
convert_expapi_ResourceConsumption_To_v1_ResourceConsumption,
|
||||
convert_expapi_ScaleSpec_To_v1_ScaleSpec,
|
||||
convert_expapi_ScaleStatus_To_v1_ScaleStatus,
|
||||
convert_expapi_Scale_To_v1_Scale,
|
||||
convert_expapi_SubresourceReference_To_v1_SubresourceReference,
|
||||
convert_expapi_TargetConsumption_To_v1_TargetConsumption,
|
||||
convert_v1_HorizontalPodAutoscalerList_To_expapi_HorizontalPodAutoscalerList,
|
||||
convert_v1_HorizontalPodAutoscalerSpec_To_expapi_HorizontalPodAutoscalerSpec,
|
||||
convert_v1_HorizontalPodAutoscalerStatus_To_expapi_HorizontalPodAutoscalerStatus,
|
||||
convert_v1_HorizontalPodAutoscaler_To_expapi_HorizontalPodAutoscaler,
|
||||
convert_v1_ListMeta_To_api_ListMeta,
|
||||
convert_v1_ObjectMeta_To_api_ObjectMeta,
|
||||
convert_v1_ReplicationControllerDummy_To_expapi_ReplicationControllerDummy,
|
||||
convert_v1_ResourceConsumption_To_expapi_ResourceConsumption,
|
||||
convert_v1_ScaleSpec_To_expapi_ScaleSpec,
|
||||
convert_v1_ScaleStatus_To_expapi_ScaleStatus,
|
||||
convert_v1_Scale_To_expapi_Scale,
|
||||
convert_v1_SubresourceReference_To_expapi_SubresourceReference,
|
||||
convert_v1_TargetConsumption_To_expapi_TargetConsumption,
|
||||
convert_v1_TypeMeta_To_api_TypeMeta,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
@ -105,6 +105,9 @@ func deepCopy_v1_HorizontalPodAutoscaler(in HorizontalPodAutoscaler, out *Horizo
|
|||
if err := deepCopy_v1_HorizontalPodAutoscalerSpec(in.Spec, &out.Spec, c); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := deepCopy_v1_HorizontalPodAutoscalerStatus(in.Status, &out.Status, c); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -139,12 +142,29 @@ func deepCopy_v1_HorizontalPodAutoscalerSpec(in HorizontalPodAutoscalerSpec, out
|
|||
}
|
||||
out.MinCount = in.MinCount
|
||||
out.MaxCount = in.MaxCount
|
||||
if err := deepCopy_v1_TargetConsumption(in.Target, &out.Target, c); err != nil {
|
||||
if err := deepCopy_v1_ResourceConsumption(in.Target, &out.Target, c); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func deepCopy_v1_HorizontalPodAutoscalerStatus(in HorizontalPodAutoscalerStatus, out *HorizontalPodAutoscalerStatus, c *conversion.Cloner) error {
|
||||
out.CurrentReplicas = in.CurrentReplicas
|
||||
out.DesiredReplicas = in.DesiredReplicas
|
||||
if err := deepCopy_v1_ResourceConsumption(in.CurrentConsumption, &out.CurrentConsumption, c); err != nil {
|
||||
return err
|
||||
}
|
||||
if in.LastScaleTimestamp != nil {
|
||||
out.LastScaleTimestamp = new(util.Time)
|
||||
if err := deepCopy_util_Time(*in.LastScaleTimestamp, out.LastScaleTimestamp, c); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.LastScaleTimestamp = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func deepCopy_v1_ReplicationControllerDummy(in ReplicationControllerDummy, out *ReplicationControllerDummy, c *conversion.Cloner) error {
|
||||
if err := deepCopy_v1_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
|
||||
return err
|
||||
|
@ -152,6 +172,14 @@ func deepCopy_v1_ReplicationControllerDummy(in ReplicationControllerDummy, out *
|
|||
return nil
|
||||
}
|
||||
|
||||
func deepCopy_v1_ResourceConsumption(in ResourceConsumption, out *ResourceConsumption, c *conversion.Cloner) error {
|
||||
out.Resource = in.Resource
|
||||
if err := deepCopy_resource_Quantity(in.Quantity, &out.Quantity, c); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func deepCopy_v1_Scale(in Scale, out *Scale, c *conversion.Cloner) error {
|
||||
if err := deepCopy_v1_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
|
||||
return err
|
||||
|
@ -195,14 +223,6 @@ func deepCopy_v1_SubresourceReference(in SubresourceReference, out *SubresourceR
|
|||
return nil
|
||||
}
|
||||
|
||||
func deepCopy_v1_TargetConsumption(in TargetConsumption, out *TargetConsumption, c *conversion.Cloner) error {
|
||||
out.Resource = in.Resource
|
||||
if err := deepCopy_resource_Quantity(in.Quantity, &out.Quantity, c); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func deepCopy_util_Time(in util.Time, out *util.Time, c *conversion.Cloner) error {
|
||||
if newVal, err := c.DeepCopy(in.Time); err != nil {
|
||||
return err
|
||||
|
@ -221,12 +241,13 @@ func init() {
|
|||
deepCopy_v1_HorizontalPodAutoscaler,
|
||||
deepCopy_v1_HorizontalPodAutoscalerList,
|
||||
deepCopy_v1_HorizontalPodAutoscalerSpec,
|
||||
deepCopy_v1_HorizontalPodAutoscalerStatus,
|
||||
deepCopy_v1_ReplicationControllerDummy,
|
||||
deepCopy_v1_ResourceConsumption,
|
||||
deepCopy_v1_Scale,
|
||||
deepCopy_v1_ScaleSpec,
|
||||
deepCopy_v1_ScaleStatus,
|
||||
deepCopy_v1_SubresourceReference,
|
||||
deepCopy_v1_TargetConsumption,
|
||||
deepCopy_util_Time,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
@ -19,6 +19,7 @@ package v1
|
|||
import (
|
||||
"k8s.io/kubernetes/pkg/api/resource"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
)
|
||||
|
||||
// ScaleSpec describes the attributes a Scale subresource
|
||||
|
@ -62,8 +63,8 @@ type SubresourceReference struct {
|
|||
Subresource string `json:"subresource,omitempty" decription:"subresource name of the referent"`
|
||||
}
|
||||
|
||||
// TargetConsumption is an object for specifying target average resource consumption of a particular resource.
|
||||
type TargetConsumption struct {
|
||||
// ResourceConsumption is an object for specifying average resource consumption of a particular resource.
|
||||
type ResourceConsumption struct {
|
||||
Resource v1.ResourceName `json:"resource,omitempty"`
|
||||
Quantity resource.Quantity `json:"quantity,omitempty"`
|
||||
}
|
||||
|
@ -79,7 +80,25 @@ type HorizontalPodAutoscalerSpec struct {
|
|||
MaxCount int `json:"maxCount" description:"upper limit for the number of pods"`
|
||||
// Target is the target average consumption of the given resource that the autoscaler will try to maintain by adjusting the desired number of pods.
|
||||
// Currently two types of resources are supported: "cpu" and "memory".
|
||||
Target TargetConsumption `json:"target" description:"target average consumption of resource that the autoscaler will try to maintain by adjusting the desired number of pods"`
|
||||
Target ResourceConsumption `json:"target" description:"target average consumption of resource that the autoscaler will try to maintain by adjusting the desired number of pods"`
|
||||
}
|
||||
|
||||
// HorizontalPodAutoscalerStatus contains the current status of a horizontal pod autoscaler
|
||||
type HorizontalPodAutoscalerStatus struct {
|
||||
// CurrentReplicas is the number of replicas of pods managed by this autoscaler.
|
||||
CurrentReplicas int `json:"replicas" description:"number of replicas observed by the autoscaler"`
|
||||
|
||||
// DesiredReplicas is the desired number of replicas of pods managed by this autoscaler.
|
||||
DesiredReplicas int `json:"replicas" description:"number of desired replicas"`
|
||||
|
||||
// CurrentConsumption is the current average consumption of the given resource that the autoscaler will
|
||||
// try to maintain by adjusting the desired number of pods.
|
||||
// Two types of resources are supported: "cpu" and "memory".
|
||||
CurrentConsumption ResourceConsumption `json:"currentConsumption" description:"current resource consumption"`
|
||||
|
||||
// LastScaleTimestamp is the last time the HorizontalPodAutoscaler scaled the number of pods.
|
||||
// This is used by the autoscaler to controll how often the number of pods is changed.
|
||||
LastScaleTimestamp *util.Time `json:"lastScaleTimestamp,omitempty" description:"last time the autoscaler made decision about changing the number of pods"`
|
||||
}
|
||||
|
||||
// HorizontalPodAutoscaler represents the configuration of a horizontal pod autoscaler.
|
||||
|
@ -89,6 +108,9 @@ type HorizontalPodAutoscaler struct {
|
|||
|
||||
// Spec defines the behaviour of autoscaler.
|
||||
Spec HorizontalPodAutoscalerSpec `json:"spec,omitempty" description:"specification of the desired behavior of the autoscaler; http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status"`
|
||||
|
||||
// Status represents the current information about the autoscaler.
|
||||
Status HorizontalPodAutoscalerStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// HorizontalPodAutoscaler is a collection of pod autoscalers.
|
||||
|
|
|
@ -38,7 +38,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
|||
},
|
||||
MinCount: 1,
|
||||
MaxCount: 5,
|
||||
Target: expapi.TargetConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
Target: expapi.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
|||
},
|
||||
MinCount: -1,
|
||||
MaxCount: 5,
|
||||
Target: expapi.TargetConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
Target: expapi.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
},
|
||||
},
|
||||
"must be bigger or equal to minCount": {
|
||||
|
@ -74,7 +74,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
|||
},
|
||||
MinCount: 7,
|
||||
MaxCount: 5,
|
||||
Target: expapi.TargetConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
Target: expapi.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
},
|
||||
},
|
||||
"invalid value": {
|
||||
|
@ -88,7 +88,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
|||
},
|
||||
MinCount: 1,
|
||||
MaxCount: 5,
|
||||
Target: expapi.TargetConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("-0.8")},
|
||||
Target: expapi.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("-0.8")},
|
||||
},
|
||||
},
|
||||
"resource not supported": {
|
||||
|
@ -102,7 +102,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
|||
},
|
||||
MinCount: 1,
|
||||
MaxCount: 5,
|
||||
Target: expapi.TargetConsumption{Resource: api.ResourceName("NotSupportedResource"), Quantity: resource.MustParse("0.8")},
|
||||
Target: expapi.ResourceConsumption{Resource: api.ResourceName("NotSupportedResource"), Quantity: resource.MustParse("0.8")},
|
||||
},
|
||||
},
|
||||
"required value": {
|
||||
|
@ -113,7 +113,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
|||
Spec: expapi.HorizontalPodAutoscalerSpec{
|
||||
MinCount: 1,
|
||||
MaxCount: 5,
|
||||
Target: expapi.TargetConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
Target: expapi.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ func validNewHorizontalPodAutoscaler(name string) *expapi.HorizontalPodAutoscale
|
|||
},
|
||||
MinCount: 1,
|
||||
MaxCount: 5,
|
||||
Target: expapi.TargetConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
Target: expapi.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue