rename v2beta2 to v2
Signed-off-by: wangyysde <net_use@bzhy.com> Generation swagger.json. Use v2 path for hpa_cpu_field. run update-codegen.sh Signed-off-by: wangyysde <net_use@bzhy.com>
This commit is contained in:
@@ -77,6 +77,8 @@ func TestDefaulting(t *testing.T) {
|
||||
{Group: "apps", Version: "v1", Kind: "StatefulSetList"}: {},
|
||||
{Group: "autoscaling", Version: "v1", Kind: "HorizontalPodAutoscaler"}: {},
|
||||
{Group: "autoscaling", Version: "v1", Kind: "HorizontalPodAutoscalerList"}: {},
|
||||
{Group: "autoscaling", Version: "v2", Kind: "HorizontalPodAutoscaler"}: {},
|
||||
{Group: "autoscaling", Version: "v2", Kind: "HorizontalPodAutoscalerList"}: {},
|
||||
{Group: "autoscaling", Version: "v2beta1", Kind: "HorizontalPodAutoscaler"}: {},
|
||||
{Group: "autoscaling", Version: "v2beta1", Kind: "HorizontalPodAutoscalerList"}: {},
|
||||
{Group: "autoscaling", Version: "v2beta2", Kind: "HorizontalPodAutoscaler"}: {},
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling/v1"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling/v2"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling/v2beta1"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling/v2beta2"
|
||||
)
|
||||
@@ -36,7 +37,9 @@ func init() {
|
||||
func Install(scheme *runtime.Scheme) {
|
||||
utilruntime.Must(autoscaling.AddToScheme(scheme))
|
||||
utilruntime.Must(v2beta2.AddToScheme(scheme))
|
||||
utilruntime.Must(v2.AddToScheme(scheme))
|
||||
utilruntime.Must(v2beta1.AddToScheme(scheme))
|
||||
utilruntime.Must(v1.AddToScheme(scheme))
|
||||
utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion, v2beta1.SchemeGroupVersion, v2beta2.SchemeGroupVersion))
|
||||
// TODO: move v2 to the front of the list in 1.24
|
||||
utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion, v2.SchemeGroupVersion, v2beta1.SchemeGroupVersion, v2beta2.SchemeGroupVersion))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2020 The Kubernetes Authors.
|
||||
Copyright 2021 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -14,29 +14,29 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v2beta2
|
||||
package v2
|
||||
|
||||
import (
|
||||
autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2"
|
||||
autoscalingv2 "k8s.io/api/autoscaling/v2"
|
||||
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
)
|
||||
|
||||
func Convert_autoscaling_HorizontalPodAutoscaler_To_v2beta2_HorizontalPodAutoscaler(in *autoscaling.HorizontalPodAutoscaler, out *autoscalingv2beta2.HorizontalPodAutoscaler, s conversion.Scope) error {
|
||||
if err := autoConvert_autoscaling_HorizontalPodAutoscaler_To_v2beta2_HorizontalPodAutoscaler(in, out, s); err != nil {
|
||||
func Convert_autoscaling_HorizontalPodAutoscaler_To_v2_HorizontalPodAutoscaler(in *autoscaling.HorizontalPodAutoscaler, out *autoscalingv2.HorizontalPodAutoscaler, s conversion.Scope) error {
|
||||
if err := autoConvert_autoscaling_HorizontalPodAutoscaler_To_v2_HorizontalPodAutoscaler(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
// v2beta2 round-trips to internal without any serialized annotations, make sure any from other versions don't get serialized
|
||||
// v2 round-trips to internal without any serialized annotations, make sure any from other versions don't get serialized
|
||||
out.Annotations, _ = autoscaling.DropRoundTripHorizontalPodAutoscalerAnnotations(out.Annotations)
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v2beta2_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler(in *autoscalingv2beta2.HorizontalPodAutoscaler, out *autoscaling.HorizontalPodAutoscaler, s conversion.Scope) error {
|
||||
if err := autoConvert_v2beta2_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler(in, out, s); err != nil {
|
||||
func Convert_v2_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler(in *autoscalingv2.HorizontalPodAutoscaler, out *autoscaling.HorizontalPodAutoscaler, s conversion.Scope) error {
|
||||
if err := autoConvert_v2_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
// v2beta2 round-trips to internal without any serialized annotations, make sure any from other versions don't get serialized
|
||||
// v2 round-trips to internal without any serialized annotations, make sure any from other versions don't get serialized
|
||||
out.Annotations, _ = autoscaling.DropRoundTripHorizontalPodAutoscalerAnnotations(out.Annotations)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 2021 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v2beta2
|
||||
package v2
|
||||
|
||||
import (
|
||||
autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2"
|
||||
autoscalingv2 "k8s.io/api/autoscaling/v2"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
@@ -29,18 +29,18 @@ var (
|
||||
scaleUpLimitMinimumPods int32 = 4
|
||||
scaleUpPeriod int32 = 15
|
||||
scaleUpStabilizationSeconds int32
|
||||
maxPolicy = autoscalingv2beta2.MaxPolicySelect
|
||||
defaultHPAScaleUpRules = autoscalingv2beta2.HPAScalingRules{
|
||||
maxPolicy = autoscalingv2.MaxChangePolicySelect
|
||||
defaultHPAScaleUpRules = autoscalingv2.HPAScalingRules{
|
||||
StabilizationWindowSeconds: &scaleUpStabilizationSeconds,
|
||||
SelectPolicy: &maxPolicy,
|
||||
Policies: []autoscalingv2beta2.HPAScalingPolicy{
|
||||
Policies: []autoscalingv2.HPAScalingPolicy{
|
||||
{
|
||||
Type: autoscalingv2beta2.PodsScalingPolicy,
|
||||
Type: autoscalingv2.PodsScalingPolicy,
|
||||
Value: scaleUpLimitMinimumPods,
|
||||
PeriodSeconds: scaleUpPeriod,
|
||||
},
|
||||
{
|
||||
Type: autoscalingv2beta2.PercentScalingPolicy,
|
||||
Type: autoscalingv2.PercentScalingPolicy,
|
||||
Value: scaleUpLimitPercent,
|
||||
PeriodSeconds: scaleUpPeriod,
|
||||
},
|
||||
@@ -49,14 +49,13 @@ var (
|
||||
scaleDownPeriod int32 = 15
|
||||
// Currently we can set the downscaleStabilizationWindow from the command line
|
||||
// So we can not rewrite the command line option from here
|
||||
scaleDownStabilizationSeconds *int32 = nil
|
||||
scaleDownLimitPercent int32 = 100
|
||||
defaultHPAScaleDownRules = autoscalingv2beta2.HPAScalingRules{
|
||||
StabilizationWindowSeconds: scaleDownStabilizationSeconds,
|
||||
scaleDownLimitPercent int32 = 100
|
||||
defaultHPAScaleDownRules = autoscalingv2.HPAScalingRules{
|
||||
StabilizationWindowSeconds: nil,
|
||||
SelectPolicy: &maxPolicy,
|
||||
Policies: []autoscalingv2beta2.HPAScalingPolicy{
|
||||
Policies: []autoscalingv2.HPAScalingPolicy{
|
||||
{
|
||||
Type: autoscalingv2beta2.PercentScalingPolicy,
|
||||
Type: autoscalingv2.PercentScalingPolicy,
|
||||
Value: scaleDownLimitPercent,
|
||||
PeriodSeconds: scaleDownPeriod,
|
||||
},
|
||||
@@ -68,7 +67,7 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
return RegisterDefaults(scheme)
|
||||
}
|
||||
|
||||
func SetDefaults_HorizontalPodAutoscaler(obj *autoscalingv2beta2.HorizontalPodAutoscaler) {
|
||||
func SetDefaults_HorizontalPodAutoscaler(obj *autoscalingv2.HorizontalPodAutoscaler) {
|
||||
if obj.Spec.MinReplicas == nil {
|
||||
minReplicas := int32(1)
|
||||
obj.Spec.MinReplicas = &minReplicas
|
||||
@@ -76,13 +75,13 @@ func SetDefaults_HorizontalPodAutoscaler(obj *autoscalingv2beta2.HorizontalPodAu
|
||||
|
||||
if len(obj.Spec.Metrics) == 0 {
|
||||
utilizationDefaultVal := int32(autoscaling.DefaultCPUUtilization)
|
||||
obj.Spec.Metrics = []autoscalingv2beta2.MetricSpec{
|
||||
obj.Spec.Metrics = []autoscalingv2.MetricSpec{
|
||||
{
|
||||
Type: autoscalingv2beta2.ResourceMetricSourceType,
|
||||
Resource: &autoscalingv2beta2.ResourceMetricSource{
|
||||
Type: autoscalingv2.ResourceMetricSourceType,
|
||||
Resource: &autoscalingv2.ResourceMetricSource{
|
||||
Name: v1.ResourceCPU,
|
||||
Target: autoscalingv2beta2.MetricTarget{
|
||||
Type: autoscalingv2beta2.UtilizationMetricType,
|
||||
Target: autoscalingv2.MetricTarget{
|
||||
Type: autoscalingv2.UtilizationMetricType,
|
||||
AverageUtilization: &utilizationDefaultVal,
|
||||
},
|
||||
},
|
||||
@@ -93,7 +92,7 @@ func SetDefaults_HorizontalPodAutoscaler(obj *autoscalingv2beta2.HorizontalPodAu
|
||||
}
|
||||
|
||||
// SetDefaults_HorizontalPodAutoscalerBehavior fills the behavior if it is not null
|
||||
func SetDefaults_HorizontalPodAutoscalerBehavior(obj *autoscalingv2beta2.HorizontalPodAutoscaler) {
|
||||
func SetDefaults_HorizontalPodAutoscalerBehavior(obj *autoscalingv2.HorizontalPodAutoscaler) {
|
||||
// if behavior is specified, we should fill all the 'nil' values with the default ones
|
||||
if obj.Spec.Behavior != nil {
|
||||
obj.Spec.Behavior.ScaleUp = GenerateHPAScaleUpRules(obj.Spec.Behavior.ScaleUp)
|
||||
@@ -103,7 +102,7 @@ func SetDefaults_HorizontalPodAutoscalerBehavior(obj *autoscalingv2beta2.Horizon
|
||||
|
||||
// GenerateHPAScaleUpRules returns a fully-initialized HPAScalingRules value
|
||||
// We guarantee that no pointer in the structure will have the 'nil' value
|
||||
func GenerateHPAScaleUpRules(scalingRules *autoscalingv2beta2.HPAScalingRules) *autoscalingv2beta2.HPAScalingRules {
|
||||
func GenerateHPAScaleUpRules(scalingRules *autoscalingv2.HPAScalingRules) *autoscalingv2.HPAScalingRules {
|
||||
defaultScalingRules := defaultHPAScaleUpRules.DeepCopy()
|
||||
return copyHPAScalingRules(scalingRules, defaultScalingRules)
|
||||
}
|
||||
@@ -111,13 +110,13 @@ func GenerateHPAScaleUpRules(scalingRules *autoscalingv2beta2.HPAScalingRules) *
|
||||
// GenerateHPAScaleDownRules returns a fully-initialized HPAScalingRules value
|
||||
// We guarantee that no pointer in the structure will have the 'nil' value
|
||||
// EXCEPT StabilizationWindowSeconds, for reasoning check the comment for defaultHPAScaleDownRules
|
||||
func GenerateHPAScaleDownRules(scalingRules *autoscalingv2beta2.HPAScalingRules) *autoscalingv2beta2.HPAScalingRules {
|
||||
func GenerateHPAScaleDownRules(scalingRules *autoscalingv2.HPAScalingRules) *autoscalingv2.HPAScalingRules {
|
||||
defaultScalingRules := defaultHPAScaleDownRules.DeepCopy()
|
||||
return copyHPAScalingRules(scalingRules, defaultScalingRules)
|
||||
}
|
||||
|
||||
// copyHPAScalingRules copies all non-`nil` fields in HPA constraint structure
|
||||
func copyHPAScalingRules(from, to *autoscalingv2beta2.HPAScalingRules) *autoscalingv2beta2.HPAScalingRules {
|
||||
func copyHPAScalingRules(from, to *autoscalingv2.HPAScalingRules) *autoscalingv2.HPAScalingRules {
|
||||
if from == nil {
|
||||
return to
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2017 The Kubernetes Authors.
|
||||
Copyright 2021 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v2beta2_test
|
||||
package v2_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
@@ -25,11 +25,11 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
autoscalingv2 "k8s.io/api/autoscaling/v2beta2"
|
||||
autoscalingv2 "k8s.io/api/autoscaling/v2"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
|
||||
. "k8s.io/kubernetes/pkg/apis/autoscaling/v2beta2"
|
||||
. "k8s.io/kubernetes/pkg/apis/autoscaling/v2"
|
||||
_ "k8s.io/kubernetes/pkg/apis/core/install"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
)
|
||||
@@ -48,8 +48,8 @@ func TestGenerateScaleDownRules(t *testing.T) {
|
||||
expectedSelectPolicy string
|
||||
annotation string
|
||||
}
|
||||
maxPolicy := autoscalingv2.MaxPolicySelect
|
||||
minPolicy := autoscalingv2.MinPolicySelect
|
||||
maxPolicy := autoscalingv2.MaxChangePolicySelect
|
||||
minPolicy := autoscalingv2.MinChangePolicySelect
|
||||
tests := []TestCase{
|
||||
{
|
||||
annotation: "Default values",
|
||||
@@ -57,7 +57,7 @@ func TestGenerateScaleDownRules(t *testing.T) {
|
||||
{Type: autoscalingv2.PercentScalingPolicy, Value: 100, PeriodSeconds: 15},
|
||||
},
|
||||
expectedStabilization: nil,
|
||||
expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect),
|
||||
expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect),
|
||||
},
|
||||
{
|
||||
annotation: "All parameters are specified",
|
||||
@@ -72,7 +72,7 @@ func TestGenerateScaleDownRules(t *testing.T) {
|
||||
{Type: autoscalingv2.PercentScalingPolicy, Value: 3, PeriodSeconds: 4},
|
||||
},
|
||||
expectedStabilization: utilpointer.Int32Ptr(25),
|
||||
expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect),
|
||||
expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect),
|
||||
},
|
||||
{
|
||||
annotation: "Percent policy is specified",
|
||||
@@ -83,7 +83,7 @@ func TestGenerateScaleDownRules(t *testing.T) {
|
||||
{Type: autoscalingv2.PercentScalingPolicy, Value: 1, PeriodSeconds: 2},
|
||||
},
|
||||
expectedStabilization: nil,
|
||||
expectedSelectPolicy: string(autoscalingv2.MinPolicySelect),
|
||||
expectedSelectPolicy: string(autoscalingv2.MinChangePolicySelect),
|
||||
},
|
||||
{
|
||||
annotation: "Pods policy is specified",
|
||||
@@ -93,7 +93,7 @@ func TestGenerateScaleDownRules(t *testing.T) {
|
||||
{Type: autoscalingv2.PodsScalingPolicy, Value: 3, PeriodSeconds: 4},
|
||||
},
|
||||
expectedStabilization: nil,
|
||||
expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect),
|
||||
expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect),
|
||||
},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
@@ -138,8 +138,8 @@ func TestGenerateScaleUpRules(t *testing.T) {
|
||||
expectedSelectPolicy string
|
||||
annotation string
|
||||
}
|
||||
maxPolicy := autoscalingv2.MaxPolicySelect
|
||||
minPolicy := autoscalingv2.MinPolicySelect
|
||||
maxPolicy := autoscalingv2.MaxChangePolicySelect
|
||||
minPolicy := autoscalingv2.MinChangePolicySelect
|
||||
tests := []TestCase{
|
||||
{
|
||||
annotation: "Default values",
|
||||
@@ -148,7 +148,7 @@ func TestGenerateScaleUpRules(t *testing.T) {
|
||||
{Type: autoscalingv2.PercentScalingPolicy, Value: 100, PeriodSeconds: 15},
|
||||
},
|
||||
expectedStabilization: utilpointer.Int32Ptr(0),
|
||||
expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect),
|
||||
expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect),
|
||||
},
|
||||
{
|
||||
annotation: "All parameters are specified",
|
||||
@@ -163,7 +163,7 @@ func TestGenerateScaleUpRules(t *testing.T) {
|
||||
{Type: autoscalingv2.PercentScalingPolicy, Value: 3, PeriodSeconds: 4},
|
||||
},
|
||||
expectedStabilization: utilpointer.Int32Ptr(25),
|
||||
expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect),
|
||||
expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect),
|
||||
},
|
||||
{
|
||||
annotation: "Pod policy is specified",
|
||||
@@ -174,7 +174,7 @@ func TestGenerateScaleUpRules(t *testing.T) {
|
||||
{Type: autoscalingv2.PodsScalingPolicy, Value: 1, PeriodSeconds: 2},
|
||||
},
|
||||
expectedStabilization: utilpointer.Int32Ptr(0),
|
||||
expectedSelectPolicy: string(autoscalingv2.MinPolicySelect),
|
||||
expectedSelectPolicy: string(autoscalingv2.MinChangePolicySelect),
|
||||
},
|
||||
{
|
||||
annotation: "Percent policy is specified",
|
||||
@@ -184,7 +184,7 @@ func TestGenerateScaleUpRules(t *testing.T) {
|
||||
{Type: autoscalingv2.PercentScalingPolicy, Value: 7, PeriodSeconds: 10},
|
||||
},
|
||||
expectedStabilization: utilpointer.Int32Ptr(0),
|
||||
expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect),
|
||||
expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect),
|
||||
},
|
||||
{
|
||||
annotation: "Pod policy and stabilization window are specified",
|
||||
@@ -195,7 +195,7 @@ func TestGenerateScaleUpRules(t *testing.T) {
|
||||
{Type: autoscalingv2.PodsScalingPolicy, Value: 4, PeriodSeconds: 2},
|
||||
},
|
||||
expectedStabilization: utilpointer.Int32Ptr(25),
|
||||
expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect),
|
||||
expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect),
|
||||
},
|
||||
{
|
||||
annotation: "Percent policy and stabilization window are specified",
|
||||
@@ -206,7 +206,7 @@ func TestGenerateScaleUpRules(t *testing.T) {
|
||||
{Type: autoscalingv2.PercentScalingPolicy, Value: 7, PeriodSeconds: 60},
|
||||
},
|
||||
expectedStabilization: utilpointer.Int32Ptr(25),
|
||||
expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect),
|
||||
expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect),
|
||||
},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 2021 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -15,8 +15,8 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/autoscaling
|
||||
// +k8s:conversion-gen-external-types=k8s.io/api/autoscaling/v2beta2
|
||||
// +k8s:conversion-gen-external-types=k8s.io/api/autoscaling/v2
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +k8s:defaulter-gen-input=../../../../vendor/k8s.io/api/autoscaling/v2beta2
|
||||
// +k8s:defaulter-gen-input=k8s.io/api/autoscaling/v2
|
||||
|
||||
package v2beta2 // import "k8s.io/kubernetes/pkg/apis/autoscaling/v2beta2"
|
||||
package v2 // import "k8s.io/kubernetes/pkg/apis/autoscaling/v2"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 2021 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v2beta2
|
||||
package v2
|
||||
|
||||
import (
|
||||
autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2"
|
||||
autoscalingv2 "k8s.io/api/autoscaling/v2"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
const GroupName = "autoscaling"
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v2beta2"}
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v2"}
|
||||
|
||||
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
@@ -33,7 +33,7 @@ func Resource(resource string) schema.GroupResource {
|
||||
}
|
||||
|
||||
var (
|
||||
localSchemeBuilder = &autoscalingv2beta2.SchemeBuilder
|
||||
localSchemeBuilder = &autoscalingv2.SchemeBuilder
|
||||
AddToScheme = localSchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
|
||||
721
pkg/apis/autoscaling/v2/zz_generated.conversion.go
generated
721
pkg/apis/autoscaling/v2/zz_generated.conversion.go
generated
File diff suppressed because it is too large
Load Diff
17
pkg/apis/autoscaling/v2/zz_generated.defaults.go
generated
17
pkg/apis/autoscaling/v2/zz_generated.defaults.go
generated
@@ -1,3 +1,4 @@
|
||||
//go:build !ignore_autogenerated
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
@@ -18,10 +19,10 @@ limitations under the License.
|
||||
|
||||
// Code generated by defaulter-gen. DO NOT EDIT.
|
||||
|
||||
package v2beta2
|
||||
package v2
|
||||
|
||||
import (
|
||||
v2beta2 "k8s.io/api/autoscaling/v2beta2"
|
||||
v2 "k8s.io/api/autoscaling/v2"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
@@ -29,20 +30,18 @@ import (
|
||||
// Public to allow building arbitrary schemes.
|
||||
// All generated defaulters are covering - they call all nested defaulters.
|
||||
func RegisterDefaults(scheme *runtime.Scheme) error {
|
||||
scheme.AddTypeDefaultingFunc(&v2beta2.HorizontalPodAutoscaler{}, func(obj interface{}) {
|
||||
SetObjectDefaults_HorizontalPodAutoscaler(obj.(*v2beta2.HorizontalPodAutoscaler))
|
||||
})
|
||||
scheme.AddTypeDefaultingFunc(&v2beta2.HorizontalPodAutoscalerList{}, func(obj interface{}) {
|
||||
SetObjectDefaults_HorizontalPodAutoscalerList(obj.(*v2beta2.HorizontalPodAutoscalerList))
|
||||
scheme.AddTypeDefaultingFunc(&v2.HorizontalPodAutoscaler{}, func(obj interface{}) { SetObjectDefaults_HorizontalPodAutoscaler(obj.(*v2.HorizontalPodAutoscaler)) })
|
||||
scheme.AddTypeDefaultingFunc(&v2.HorizontalPodAutoscalerList{}, func(obj interface{}) {
|
||||
SetObjectDefaults_HorizontalPodAutoscalerList(obj.(*v2.HorizontalPodAutoscalerList))
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_HorizontalPodAutoscaler(in *v2beta2.HorizontalPodAutoscaler) {
|
||||
func SetObjectDefaults_HorizontalPodAutoscaler(in *v2.HorizontalPodAutoscaler) {
|
||||
SetDefaults_HorizontalPodAutoscaler(in)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_HorizontalPodAutoscalerList(in *v2beta2.HorizontalPodAutoscalerList) {
|
||||
func SetObjectDefaults_HorizontalPodAutoscalerList(in *v2.HorizontalPodAutoscalerList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_HorizontalPodAutoscaler(a)
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"time"
|
||||
|
||||
autoscalingv1 "k8s.io/api/autoscaling/v1"
|
||||
autoscalingv2 "k8s.io/api/autoscaling/v2beta2"
|
||||
autoscalingv2 "k8s.io/api/autoscaling/v2"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
@@ -1046,7 +1046,7 @@ func calculateScaleUpLimitWithScalingRules(currentReplicas int32, scaleEvents []
|
||||
var selectPolicyFn func(int32, int32) int32
|
||||
if *scalingRules.SelectPolicy == autoscalingv2.DisabledPolicySelect {
|
||||
return currentReplicas // Scaling is disabled
|
||||
} else if *scalingRules.SelectPolicy == autoscalingv2.MinPolicySelect {
|
||||
} else if *scalingRules.SelectPolicy == autoscalingv2.MinChangePolicySelect {
|
||||
result = math.MaxInt32
|
||||
selectPolicyFn = min // For scaling up, the lowest change ('min' policy) produces a minimum value
|
||||
} else {
|
||||
@@ -1074,7 +1074,7 @@ func calculateScaleDownLimitWithBehaviors(currentReplicas int32, scaleEvents []t
|
||||
var selectPolicyFn func(int32, int32) int32
|
||||
if *scalingRules.SelectPolicy == autoscalingv2.DisabledPolicySelect {
|
||||
return currentReplicas // Scaling is disabled
|
||||
} else if *scalingRules.SelectPolicy == autoscalingv2.MinPolicySelect {
|
||||
} else if *scalingRules.SelectPolicy == autoscalingv2.MinChangePolicySelect {
|
||||
result = math.MinInt32
|
||||
selectPolicyFn = max // For scaling down, the lowest change ('min' policy) produces a maximum value
|
||||
} else {
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
"time"
|
||||
|
||||
autoscalingv1 "k8s.io/api/autoscaling/v1"
|
||||
autoscalingv2 "k8s.io/api/autoscaling/v2beta2"
|
||||
autoscalingv2 "k8s.io/api/autoscaling/v2"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/meta/testrestmapper"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
@@ -41,7 +41,7 @@ import (
|
||||
core "k8s.io/client-go/testing"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
autoscalingapiv2beta2 "k8s.io/kubernetes/pkg/apis/autoscaling/v2beta2"
|
||||
autoscalingapiv2 "k8s.io/kubernetes/pkg/apis/autoscaling/v2"
|
||||
"k8s.io/kubernetes/pkg/controller"
|
||||
"k8s.io/kubernetes/pkg/controller/podautoscaler/metrics"
|
||||
cmapi "k8s.io/metrics/pkg/apis/custom_metrics/v1beta2"
|
||||
@@ -230,7 +230,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) (*fake.Clientset, *metricsfa
|
||||
},
|
||||
}
|
||||
// Initialize default values
|
||||
autoscalingapiv2beta2.SetDefaults_HorizontalPodAutoscalerBehavior(&hpa)
|
||||
autoscalingapiv2.SetDefaults_HorizontalPodAutoscalerBehavior(&hpa)
|
||||
|
||||
obj := &autoscalingv2.HorizontalPodAutoscalerList{
|
||||
Items: []autoscalingv2.HorizontalPodAutoscaler{hpa},
|
||||
@@ -2982,7 +2982,7 @@ func TestConvertDesiredReplicasWithRules(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCalculateScaleUpLimitWithScalingRules(t *testing.T) {
|
||||
policy := autoscalingv2.MinPolicySelect
|
||||
policy := autoscalingv2.MinChangePolicySelect
|
||||
|
||||
calculated := calculateScaleUpLimitWithScalingRules(1, []timestampedScaleEvent{}, &autoscalingv2.HPAScalingRules{
|
||||
StabilizationWindowSeconds: utilpointer.Int32Ptr(300),
|
||||
@@ -3004,7 +3004,7 @@ func TestCalculateScaleUpLimitWithScalingRules(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCalculateScaleDownLimitWithBehaviors(t *testing.T) {
|
||||
policy := autoscalingv2.MinPolicySelect
|
||||
policy := autoscalingv2.MinChangePolicySelect
|
||||
|
||||
calculated := calculateScaleDownLimitWithBehaviors(5, []timestampedScaleEvent{}, &autoscalingv2.HPAScalingRules{
|
||||
StabilizationWindowSeconds: utilpointer.Int32Ptr(300),
|
||||
@@ -3026,7 +3026,7 @@ func TestCalculateScaleDownLimitWithBehaviors(t *testing.T) {
|
||||
}
|
||||
|
||||
func generateScalingRules(pods, podsPeriod, percent, percentPeriod, stabilizationWindow int32) *autoscalingv2.HPAScalingRules {
|
||||
policy := autoscalingv2.MaxPolicySelect
|
||||
policy := autoscalingv2.MaxChangePolicySelect
|
||||
directionBehavior := autoscalingv2.HPAScalingRules{
|
||||
StabilizationWindowSeconds: utilpointer.Int32Ptr(stabilizationWindow),
|
||||
SelectPolicy: &policy,
|
||||
@@ -3610,8 +3610,8 @@ func TestScalingWithRules(t *testing.T) {
|
||||
}
|
||||
arg := NormalizationArg{
|
||||
Key: tc.key,
|
||||
ScaleUpBehavior: autoscalingapiv2beta2.GenerateHPAScaleUpRules(tc.scaleUpRules),
|
||||
ScaleDownBehavior: autoscalingapiv2beta2.GenerateHPAScaleDownRules(tc.scaleDownRules),
|
||||
ScaleUpBehavior: autoscalingapiv2.GenerateHPAScaleUpRules(tc.scaleUpRules),
|
||||
ScaleDownBehavior: autoscalingapiv2.GenerateHPAScaleDownRules(tc.scaleDownRules),
|
||||
MinReplicas: tc.specMinReplicas,
|
||||
MaxReplicas: tc.specMaxReplicas,
|
||||
DesiredReplicas: tc.prenormalizedDesiredReplicas,
|
||||
|
||||
@@ -23,8 +23,8 @@ import (
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
autoscaling "k8s.io/api/autoscaling/v2beta2"
|
||||
"k8s.io/api/core/v1"
|
||||
autoscaling "k8s.io/api/autoscaling/v2"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
autoscalingapi "k8s.io/api/autoscaling/v2beta2"
|
||||
"k8s.io/api/core/v1"
|
||||
autoscalingapi "k8s.io/api/autoscaling/v2"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/meta/testrestmapper"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
@@ -20,8 +20,8 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
autoscaling "k8s.io/api/autoscaling/v2beta2"
|
||||
"k8s.io/api/core/v1"
|
||||
autoscaling "k8s.io/api/autoscaling/v2"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
)
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
autoscaling "k8s.io/api/autoscaling/v2beta2"
|
||||
autoscaling "k8s.io/api/autoscaling/v2"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
autoscalingv2 "k8s.io/api/autoscaling/v2beta2"
|
||||
autoscalingv2 "k8s.io/api/autoscaling/v2"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/meta/testrestmapper"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
|
||||
@@ -31,6 +31,7 @@ import (
|
||||
authenticationv1 "k8s.io/api/authentication/v1"
|
||||
authorizationapiv1 "k8s.io/api/authorization/v1"
|
||||
autoscalingapiv1 "k8s.io/api/autoscaling/v1"
|
||||
autoscalingapiv2 "k8s.io/api/autoscaling/v2"
|
||||
autoscalingapiv2beta1 "k8s.io/api/autoscaling/v2beta1"
|
||||
autoscalingapiv2beta2 "k8s.io/api/autoscaling/v2beta2"
|
||||
batchapiv1 "k8s.io/api/batch/v1"
|
||||
@@ -646,6 +647,7 @@ func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig {
|
||||
authenticationv1.SchemeGroupVersion,
|
||||
authorizationapiv1.SchemeGroupVersion,
|
||||
autoscalingapiv1.SchemeGroupVersion,
|
||||
autoscalingapiv2.SchemeGroupVersion,
|
||||
autoscalingapiv2beta1.SchemeGroupVersion,
|
||||
autoscalingapiv2beta2.SchemeGroupVersion,
|
||||
batchapiv1.SchemeGroupVersion,
|
||||
|
||||
@@ -52,6 +52,7 @@ var GVRToStorageVersionHash = map[string]string{
|
||||
"v1/serviceaccounts": "pbx9ZvyFpBE=",
|
||||
"v1/services": "0/CO1lhkEBI=",
|
||||
"autoscaling/v1/horizontalpodautoscalers": "oQlkt7f5j/A=",
|
||||
"autoscaling/v2/horizontalpodautoscalers": "oQlkt7f5j/A=",
|
||||
"autoscaling/v2beta1/horizontalpodautoscalers": "oQlkt7f5j/A=",
|
||||
"autoscaling/v2beta2/horizontalpodautoscalers": "oQlkt7f5j/A=",
|
||||
"batch/v1/jobs": "mudhfqk/qZY=",
|
||||
|
||||
@@ -52,6 +52,9 @@ func (autoscalerStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.S
|
||||
"autoscaling/v1": fieldpath.NewSet(
|
||||
fieldpath.MakePathOrDie("status"),
|
||||
),
|
||||
"autoscaling/v2": fieldpath.NewSet(
|
||||
fieldpath.MakePathOrDie("status"),
|
||||
),
|
||||
"autoscaling/v2beta1": fieldpath.NewSet(
|
||||
fieldpath.MakePathOrDie("status"),
|
||||
),
|
||||
@@ -151,6 +154,9 @@ func (autoscalerStatusStrategy) GetResetFields() map[fieldpath.APIVersion]*field
|
||||
"autoscaling/v1": fieldpath.NewSet(
|
||||
fieldpath.MakePathOrDie("spec"),
|
||||
),
|
||||
"autoscaling/v2": fieldpath.NewSet(
|
||||
fieldpath.MakePathOrDie("spec"),
|
||||
),
|
||||
"autoscaling/v2beta1": fieldpath.NewSet(
|
||||
fieldpath.MakePathOrDie("spec"),
|
||||
),
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
serverstorage "k8s.io/apiserver/pkg/server/storage"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
autoscalingapiv2 "k8s.io/kubernetes/pkg/apis/autoscaling/v2"
|
||||
autoscalingapiv2beta2 "k8s.io/kubernetes/pkg/apis/autoscaling/v2beta2"
|
||||
horizontalpodautoscalerstore "k8s.io/kubernetes/pkg/registry/autoscaling/horizontalpodautoscaler/storage"
|
||||
)
|
||||
@@ -43,6 +44,13 @@ func (p RESTStorageProvider) NewRESTStorage(apiResourceConfigSource serverstorag
|
||||
apiGroupInfo.VersionedResourcesStorageMap[autoscalingapiv2beta2.SchemeGroupVersion.Version] = storageMap
|
||||
}
|
||||
}
|
||||
if apiResourceConfigSource.VersionEnabled(autoscalingapiv2.SchemeGroupVersion) {
|
||||
if storageMap, err := p.v2Storage(apiResourceConfigSource, restOptionsGetter); err != nil {
|
||||
return genericapiserver.APIGroupInfo{}, false, err
|
||||
} else {
|
||||
apiGroupInfo.VersionedResourcesStorageMap[autoscalingapiv2.SchemeGroupVersion.Version] = storageMap
|
||||
}
|
||||
}
|
||||
if apiResourceConfigSource.VersionEnabled(autoscalingapiv2beta1.SchemeGroupVersion) {
|
||||
if storageMap, err := p.v2beta1Storage(apiResourceConfigSource, restOptionsGetter); err != nil {
|
||||
return genericapiserver.APIGroupInfo{}, false, err
|
||||
@@ -100,6 +108,19 @@ func (p RESTStorageProvider) v2beta2Storage(apiResourceConfigSource serverstorag
|
||||
return storage, err
|
||||
}
|
||||
|
||||
func (p RESTStorageProvider) v2Storage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) (map[string]rest.Storage, error) {
|
||||
storage := map[string]rest.Storage{}
|
||||
// horizontalpodautoscalers
|
||||
hpaStorage, hpaStatusStorage, err := horizontalpodautoscalerstore.NewREST(restOptionsGetter)
|
||||
if err != nil {
|
||||
return storage, err
|
||||
}
|
||||
storage["horizontalpodautoscalers"] = hpaStorage
|
||||
storage["horizontalpodautoscalers/status"] = hpaStatusStorage
|
||||
|
||||
return storage, err
|
||||
}
|
||||
|
||||
func (p RESTStorageProvider) GroupName() string {
|
||||
return autoscaling.GroupName
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user