mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 10:18:13 +00:00 
			
		
		
		
	Removed HPA objects from extensions api group
This commit is contained in:
		| @@ -44,9 +44,7 @@ import ( | |||||||
| 	"k8s.io/apiserver/pkg/server/filters" | 	"k8s.io/apiserver/pkg/server/filters" | ||||||
| 	"k8s.io/kubernetes/cmd/kube-apiserver/app/options" | 	"k8s.io/kubernetes/cmd/kube-apiserver/app/options" | ||||||
| 	"k8s.io/kubernetes/pkg/api" | 	"k8s.io/kubernetes/pkg/api" | ||||||
| 	"k8s.io/kubernetes/pkg/apis/autoscaling" |  | ||||||
| 	"k8s.io/kubernetes/pkg/apis/batch" | 	"k8s.io/kubernetes/pkg/apis/batch" | ||||||
| 	"k8s.io/kubernetes/pkg/apis/extensions" |  | ||||||
| 	"k8s.io/kubernetes/pkg/capabilities" | 	"k8s.io/kubernetes/pkg/capabilities" | ||||||
| 	"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" | 	"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" | ||||||
| 	"k8s.io/kubernetes/pkg/cloudprovider" | 	"k8s.io/kubernetes/pkg/cloudprovider" | ||||||
| @@ -202,7 +200,6 @@ func Run(s *options.ServerRunOptions) error { | |||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return fmt.Errorf("error in initializing storage factory: %s", err) | 		return fmt.Errorf("error in initializing storage factory: %s", err) | ||||||
| 	} | 	} | ||||||
| 	storageFactory.AddCohabitatingResources(autoscaling.Resource("horizontalpodautoscalers"), extensions.Resource("horizontalpodautoscalers")) |  | ||||||
| 	for _, override := range s.Etcd.EtcdServersOverrides { | 	for _, override := range s.Etcd.EtcdServersOverrides { | ||||||
| 		tokens := strings.Split(override, "#") | 		tokens := strings.Split(override, "#") | ||||||
| 		if len(tokens) != 2 { | 		if len(tokens) != 2 { | ||||||
|   | |||||||
| @@ -1015,12 +1015,10 @@ run_save_config_tests() { | |||||||
|   # Command: autoscale rc "frontend" |   # Command: autoscale rc "frontend" | ||||||
|   kubectl autoscale -f hack/testdata/frontend-controller.yaml --save-config "${kube_flags[@]}" --max=2 |   kubectl autoscale -f hack/testdata/frontend-controller.yaml --save-config "${kube_flags[@]}" --max=2 | ||||||
|   # Post-Condition: hpa "frontend" has configuration annotation |   # Post-Condition: hpa "frontend" has configuration annotation | ||||||
|   [[ "$(kubectl get hpa.v1beta1.extensions frontend -o yaml "${kube_flags[@]}" | grep kubectl.kubernetes.io/last-applied-configuration)" ]] |   [[ "$(kubectl get hpa frontend -o yaml "${kube_flags[@]}" | grep kubectl.kubernetes.io/last-applied-configuration)" ]] | ||||||
|   # Ensure we can interact with HPA objects in lists through both the extensions/v1beta1 and autoscaling/v1 APIs |   # Ensure we can interact with HPA objects in lists through autoscaling/v1 APIs | ||||||
|   output_message=$(kubectl get hpa -o=jsonpath='{.items[0].apiVersion}' 2>&1 "${kube_flags[@]}") |   output_message=$(kubectl get hpa -o=jsonpath='{.items[0].apiVersion}' 2>&1 "${kube_flags[@]}") | ||||||
|   kube::test::if_has_string "${output_message}" 'autoscaling/v1' |   kube::test::if_has_string "${output_message}" 'autoscaling/v1' | ||||||
|   output_message=$(kubectl get hpa.extensions -o=jsonpath='{.items[0].apiVersion}' 2>&1 "${kube_flags[@]}") |  | ||||||
|   kube::test::if_has_string "${output_message}" 'extensions/v1beta1' |  | ||||||
|   output_message=$(kubectl get hpa.autoscaling -o=jsonpath='{.items[0].apiVersion}' 2>&1 "${kube_flags[@]}") |   output_message=$(kubectl get hpa.autoscaling -o=jsonpath='{.items[0].apiVersion}' 2>&1 "${kube_flags[@]}") | ||||||
|   kube::test::if_has_string "${output_message}" 'autoscaling/v1' |   kube::test::if_has_string "${output_message}" 'autoscaling/v1' | ||||||
|   # tests kubectl group prefix matching |   # tests kubectl group prefix matching | ||||||
| @@ -2111,18 +2109,10 @@ run_rc_tests() { | |||||||
|   kubectl autoscale -f hack/testdata/frontend-controller.yaml "${kube_flags[@]}" --max=2 --cpu-percent=70 |   kubectl autoscale -f hack/testdata/frontend-controller.yaml "${kube_flags[@]}" --max=2 --cpu-percent=70 | ||||||
|   kube::test::get_object_assert 'hpa frontend' "{{$hpa_min_field}} {{$hpa_max_field}} {{$hpa_cpu_field}}" '1 2 70' |   kube::test::get_object_assert 'hpa frontend' "{{$hpa_min_field}} {{$hpa_max_field}} {{$hpa_cpu_field}}" '1 2 70' | ||||||
|   kubectl delete hpa frontend "${kube_flags[@]}" |   kubectl delete hpa frontend "${kube_flags[@]}" | ||||||
|   # autoscale 1~2 pods, CPU utilization 70%, rc specified by file, using old generator |  | ||||||
|   kubectl autoscale -f hack/testdata/frontend-controller.yaml "${kube_flags[@]}" --max=2 --cpu-percent=70 --generator=horizontalpodautoscaler/v1beta1 |  | ||||||
|   kube::test::get_object_assert 'hpa frontend' "{{$hpa_min_field}} {{$hpa_max_field}} {{$hpa_cpu_field}}" '1 2 70' |  | ||||||
|   kubectl delete hpa frontend "${kube_flags[@]}" |  | ||||||
|   # autoscale 2~3 pods, no CPU utilization specified, rc specified by name |   # autoscale 2~3 pods, no CPU utilization specified, rc specified by name | ||||||
|   kubectl autoscale rc frontend "${kube_flags[@]}" --min=2 --max=3 |   kubectl autoscale rc frontend "${kube_flags[@]}" --min=2 --max=3 | ||||||
|   kube::test::get_object_assert 'hpa frontend' "{{$hpa_min_field}} {{$hpa_max_field}} {{$hpa_cpu_field}}" '2 3 <no value>' |   kube::test::get_object_assert 'hpa frontend' "{{$hpa_min_field}} {{$hpa_max_field}} {{$hpa_cpu_field}}" '2 3 <no value>' | ||||||
|   kubectl delete hpa frontend "${kube_flags[@]}" |   kubectl delete hpa frontend "${kube_flags[@]}" | ||||||
|   # autoscale 2~3 pods, no CPU utilization specified, rc specified by name, using old generator |  | ||||||
|   kubectl autoscale rc frontend "${kube_flags[@]}" --min=2 --max=3 --generator=horizontalpodautoscaler/v1beta1 |  | ||||||
|   kube::test::get_object_assert 'hpa frontend' "{{$hpa_min_field}} {{$hpa_max_field}} {{$hpa_cpu_field}}" '2 3 <no value>' |  | ||||||
|   kubectl delete hpa frontend "${kube_flags[@]}" |  | ||||||
|   # autoscale without specifying --max should fail |   # autoscale without specifying --max should fail | ||||||
|   ! kubectl autoscale rc frontend "${kube_flags[@]}" |   ! kubectl autoscale rc frontend "${kube_flags[@]}" | ||||||
|   # Clean up |   # Clean up | ||||||
|   | |||||||
| @@ -107,16 +107,17 @@ echo "${ETCD_VERSION}/${STORAGE_BACKEND_ETCD2}" > "${ETCD_DIR}/version.txt" | |||||||
|  |  | ||||||
| ### BEGIN TEST DEFINITION CUSTOMIZATION ### | ### BEGIN TEST DEFINITION CUSTOMIZATION ### | ||||||
|  |  | ||||||
|  | # After removing HPA in v1beta1 there is basically no resource which has | ||||||
|  | # two versions. In the future we may want to extend it. | ||||||
| # source_file,resource,namespace,name,old_version,new_version | # source_file,resource,namespace,name,old_version,new_version | ||||||
| tests=( | tests=( | ||||||
| test/fixtures/doc-yaml/user-guide/horizontal-pod-autoscaling/hpa-php-apache.yaml,horizontalpodautoscalers,default,php-apache,extensions/v1beta1,autoscaling/v1 | test/fixtures/doc-yaml/user-guide/pod.yaml,pods,default,nginx,v1,v1 | ||||||
| ) | ) | ||||||
|  |  | ||||||
| # need to include extensions/v1beta1 in new api version because its internal types are used by hpas |  | ||||||
| KUBE_OLD_API_VERSION="v1,extensions/v1beta1" | KUBE_OLD_API_VERSION="v1,extensions/v1beta1" | ||||||
| KUBE_NEW_API_VERSION="v1,extensions/v1beta1,autoscaling/v1" | KUBE_NEW_API_VERSION="v1,extensions/v1beta1" | ||||||
| KUBE_OLD_STORAGE_VERSIONS="autoscaling=extensions/v1beta1" | KUBE_OLD_STORAGE_VERSIONS="v1" | ||||||
| KUBE_NEW_STORAGE_VERSIONS="autoscaling/v1" | KUBE_NEW_STORAGE_VERSIONS="v1" | ||||||
|  |  | ||||||
| ### END TEST DEFINITION CUSTOMIZATION ### | ### END TEST DEFINITION CUSTOMIZATION ### | ||||||
|  |  | ||||||
|   | |||||||
| @@ -104,8 +104,6 @@ func TestDefaulting(t *testing.T) { | |||||||
| 		{Group: "extensions", Version: "v1beta1", Kind: "DaemonSetList"}:                          {}, | 		{Group: "extensions", Version: "v1beta1", Kind: "DaemonSetList"}:                          {}, | ||||||
| 		{Group: "extensions", Version: "v1beta1", Kind: "Deployment"}:                             {}, | 		{Group: "extensions", Version: "v1beta1", Kind: "Deployment"}:                             {}, | ||||||
| 		{Group: "extensions", Version: "v1beta1", Kind: "DeploymentList"}:                         {}, | 		{Group: "extensions", Version: "v1beta1", Kind: "DeploymentList"}:                         {}, | ||||||
| 		{Group: "extensions", Version: "v1beta1", Kind: "HorizontalPodAutoscaler"}:                {}, |  | ||||||
| 		{Group: "extensions", Version: "v1beta1", Kind: "HorizontalPodAutoscalerList"}:            {}, |  | ||||||
| 		{Group: "extensions", Version: "v1beta1", Kind: "ReplicaSet"}:                             {}, | 		{Group: "extensions", Version: "v1beta1", Kind: "ReplicaSet"}:                             {}, | ||||||
| 		{Group: "extensions", Version: "v1beta1", Kind: "ReplicaSetList"}:                         {}, | 		{Group: "extensions", Version: "v1beta1", Kind: "ReplicaSetList"}:                         {}, | ||||||
| 		{Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Kind: "ClusterRoleBinding"}:     {}, | 		{Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Kind: "ClusterRoleBinding"}:     {}, | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package extensions | |||||||
| import ( | import ( | ||||||
| 	"k8s.io/apimachinery/pkg/runtime" | 	"k8s.io/apimachinery/pkg/runtime" | ||||||
| 	"k8s.io/apimachinery/pkg/runtime/schema" | 	"k8s.io/apimachinery/pkg/runtime/schema" | ||||||
| 	"k8s.io/kubernetes/pkg/apis/autoscaling" |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // GroupName is the group name use in this package | // GroupName is the group name use in this package | ||||||
| @@ -50,8 +49,6 @@ func addKnownTypes(scheme *runtime.Scheme) error { | |||||||
| 		&Deployment{}, | 		&Deployment{}, | ||||||
| 		&DeploymentList{}, | 		&DeploymentList{}, | ||||||
| 		&DeploymentRollback{}, | 		&DeploymentRollback{}, | ||||||
| 		&autoscaling.HorizontalPodAutoscaler{}, |  | ||||||
| 		&autoscaling.HorizontalPodAutoscalerList{}, |  | ||||||
| 		&ReplicationControllerDummy{}, | 		&ReplicationControllerDummy{}, | ||||||
| 		&Scale{}, | 		&Scale{}, | ||||||
| 		&ThirdPartyResource{}, | 		&ThirdPartyResource{}, | ||||||
|   | |||||||
| @@ -25,7 +25,6 @@ import ( | |||||||
| 	"k8s.io/apimachinery/pkg/util/intstr" | 	"k8s.io/apimachinery/pkg/util/intstr" | ||||||
| 	"k8s.io/kubernetes/pkg/api" | 	"k8s.io/kubernetes/pkg/api" | ||||||
| 	v1 "k8s.io/kubernetes/pkg/api/v1" | 	v1 "k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	"k8s.io/kubernetes/pkg/apis/autoscaling" |  | ||||||
| 	"k8s.io/kubernetes/pkg/apis/extensions" | 	"k8s.io/kubernetes/pkg/apis/extensions" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -42,11 +41,6 @@ func addConversionFuncs(scheme *runtime.Scheme) error { | |||||||
| 		Convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment, | 		Convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment, | ||||||
| 		Convert_extensions_ReplicaSetSpec_To_v1beta1_ReplicaSetSpec, | 		Convert_extensions_ReplicaSetSpec_To_v1beta1_ReplicaSetSpec, | ||||||
| 		Convert_v1beta1_ReplicaSetSpec_To_extensions_ReplicaSetSpec, | 		Convert_v1beta1_ReplicaSetSpec_To_extensions_ReplicaSetSpec, | ||||||
| 		// autoscaling |  | ||||||
| 		Convert_autoscaling_CrossVersionObjectReference_To_v1beta1_SubresourceReference, |  | ||||||
| 		Convert_v1beta1_SubresourceReference_To_autoscaling_CrossVersionObjectReference, |  | ||||||
| 		Convert_autoscaling_HorizontalPodAutoscalerSpec_To_v1beta1_HorizontalPodAutoscalerSpec, |  | ||||||
| 		Convert_v1beta1_HorizontalPodAutoscalerSpec_To_autoscaling_HorizontalPodAutoscalerSpec, |  | ||||||
| 	) | 	) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| @@ -248,53 +242,3 @@ func Convert_v1beta1_ReplicaSetSpec_To_extensions_ReplicaSetSpec(in *ReplicaSetS | |||||||
| 	} | 	} | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func Convert_autoscaling_CrossVersionObjectReference_To_v1beta1_SubresourceReference(in *autoscaling.CrossVersionObjectReference, out *SubresourceReference, s conversion.Scope) error { |  | ||||||
| 	out.Kind = in.Kind |  | ||||||
| 	out.Name = in.Name |  | ||||||
| 	out.APIVersion = in.APIVersion |  | ||||||
| 	out.Subresource = "scale" |  | ||||||
| 	return nil |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func Convert_v1beta1_SubresourceReference_To_autoscaling_CrossVersionObjectReference(in *SubresourceReference, out *autoscaling.CrossVersionObjectReference, s conversion.Scope) error { |  | ||||||
| 	out.Kind = in.Kind |  | ||||||
| 	out.Name = in.Name |  | ||||||
| 	out.APIVersion = in.APIVersion |  | ||||||
| 	return nil |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func Convert_autoscaling_HorizontalPodAutoscalerSpec_To_v1beta1_HorizontalPodAutoscalerSpec(in *autoscaling.HorizontalPodAutoscalerSpec, out *HorizontalPodAutoscalerSpec, s conversion.Scope) error { |  | ||||||
| 	if err := Convert_autoscaling_CrossVersionObjectReference_To_v1beta1_SubresourceReference(&in.ScaleTargetRef, &out.ScaleRef, s); err != nil { |  | ||||||
| 		return err |  | ||||||
| 	} |  | ||||||
| 	if in.MinReplicas != nil { |  | ||||||
| 		out.MinReplicas = new(int32) |  | ||||||
| 		*out.MinReplicas = *in.MinReplicas |  | ||||||
| 	} else { |  | ||||||
| 		out.MinReplicas = nil |  | ||||||
| 	} |  | ||||||
| 	out.MaxReplicas = in.MaxReplicas |  | ||||||
| 	if in.TargetCPUUtilizationPercentage != nil { |  | ||||||
| 		out.CPUUtilization = &CPUTargetUtilization{TargetPercentage: *in.TargetCPUUtilizationPercentage} |  | ||||||
| 	} |  | ||||||
| 	return nil |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func Convert_v1beta1_HorizontalPodAutoscalerSpec_To_autoscaling_HorizontalPodAutoscalerSpec(in *HorizontalPodAutoscalerSpec, out *autoscaling.HorizontalPodAutoscalerSpec, s conversion.Scope) error { |  | ||||||
| 	if err := Convert_v1beta1_SubresourceReference_To_autoscaling_CrossVersionObjectReference(&in.ScaleRef, &out.ScaleTargetRef, s); err != nil { |  | ||||||
| 		return err |  | ||||||
| 	} |  | ||||||
| 	if in.MinReplicas != nil { |  | ||||||
| 		out.MinReplicas = new(int32) |  | ||||||
| 		*out.MinReplicas = int32(*in.MinReplicas) |  | ||||||
| 	} else { |  | ||||||
| 		out.MinReplicas = nil |  | ||||||
| 	} |  | ||||||
| 	out.MaxReplicas = int32(in.MaxReplicas) |  | ||||||
| 	if in.CPUUtilization != nil { |  | ||||||
| 		out.TargetCPUUtilizationPercentage = new(int32) |  | ||||||
| 		*out.TargetCPUUtilizationPercentage = int32(in.CPUUtilization.TargetPercentage) |  | ||||||
| 	} |  | ||||||
| 	return nil |  | ||||||
| } |  | ||||||
|   | |||||||
| @@ -28,7 +28,6 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error { | |||||||
| 	return scheme.AddDefaultingFuncs( | 	return scheme.AddDefaultingFuncs( | ||||||
| 		SetDefaults_DaemonSet, | 		SetDefaults_DaemonSet, | ||||||
| 		SetDefaults_Deployment, | 		SetDefaults_Deployment, | ||||||
| 		SetDefaults_HorizontalPodAutoscaler, |  | ||||||
| 		SetDefaults_ReplicaSet, | 		SetDefaults_ReplicaSet, | ||||||
| 		SetDefaults_NetworkPolicy, | 		SetDefaults_NetworkPolicy, | ||||||
| 	) | 	) | ||||||
| @@ -90,16 +89,6 @@ func SetDefaults_Deployment(obj *Deployment) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| func SetDefaults_HorizontalPodAutoscaler(obj *HorizontalPodAutoscaler) { |  | ||||||
| 	if obj.Spec.MinReplicas == nil { |  | ||||||
| 		minReplicas := int32(1) |  | ||||||
| 		obj.Spec.MinReplicas = &minReplicas |  | ||||||
| 	} |  | ||||||
| 	if obj.Spec.CPUUtilization == nil { |  | ||||||
| 		obj.Spec.CPUUtilization = &CPUTargetUtilization{TargetPercentage: 80} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func SetDefaults_ReplicaSet(obj *ReplicaSet) { | func SetDefaults_ReplicaSet(obj *ReplicaSet) { | ||||||
| 	labels := obj.Spec.Template.Labels | 	labels := obj.Spec.Template.Labels | ||||||
|  |  | ||||||
|   | |||||||
| @@ -499,78 +499,6 @@ func TestDefaultRequestIsNotSetForReplicaSet(t *testing.T) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| func TestSetDefaultHorizontalPodAutoscalerMinReplicas(t *testing.T) { |  | ||||||
| 	tests := []struct { |  | ||||||
| 		hpa            HorizontalPodAutoscaler |  | ||||||
| 		expectReplicas int32 |  | ||||||
| 	}{ |  | ||||||
| 		{ |  | ||||||
| 			hpa:            HorizontalPodAutoscaler{}, |  | ||||||
| 			expectReplicas: 1, |  | ||||||
| 		}, |  | ||||||
| 		{ |  | ||||||
| 			hpa: HorizontalPodAutoscaler{ |  | ||||||
| 				Spec: HorizontalPodAutoscalerSpec{ |  | ||||||
| 					MinReplicas: newInt32(3), |  | ||||||
| 				}, |  | ||||||
| 			}, |  | ||||||
| 			expectReplicas: 3, |  | ||||||
| 		}, |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	for _, test := range tests { |  | ||||||
| 		hpa := &test.hpa |  | ||||||
| 		obj2 := roundTrip(t, runtime.Object(hpa)) |  | ||||||
| 		hpa2, ok := obj2.(*HorizontalPodAutoscaler) |  | ||||||
| 		if !ok { |  | ||||||
| 			t.Errorf("unexpected object: %v", hpa2) |  | ||||||
| 			t.FailNow() |  | ||||||
| 		} |  | ||||||
| 		if hpa2.Spec.MinReplicas == nil { |  | ||||||
| 			t.Errorf("unexpected nil MinReplicas") |  | ||||||
| 		} else if test.expectReplicas != *hpa2.Spec.MinReplicas { |  | ||||||
| 			t.Errorf("expected: %d MinReplicas, got: %d", test.expectReplicas, *hpa2.Spec.MinReplicas) |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func TestSetDefaultHorizontalPodAutoscalerCpuUtilization(t *testing.T) { |  | ||||||
| 	tests := []struct { |  | ||||||
| 		hpa               HorizontalPodAutoscaler |  | ||||||
| 		expectUtilization int32 |  | ||||||
| 	}{ |  | ||||||
| 		{ |  | ||||||
| 			hpa:               HorizontalPodAutoscaler{}, |  | ||||||
| 			expectUtilization: 80, |  | ||||||
| 		}, |  | ||||||
| 		{ |  | ||||||
| 			hpa: HorizontalPodAutoscaler{ |  | ||||||
| 				Spec: HorizontalPodAutoscalerSpec{ |  | ||||||
| 					CPUUtilization: &CPUTargetUtilization{ |  | ||||||
| 						TargetPercentage: int32(50), |  | ||||||
| 					}, |  | ||||||
| 				}, |  | ||||||
| 			}, |  | ||||||
| 			expectUtilization: 50, |  | ||||||
| 		}, |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	for _, test := range tests { |  | ||||||
| 		hpa := &test.hpa |  | ||||||
| 		obj2 := roundTrip(t, runtime.Object(hpa)) |  | ||||||
| 		hpa2, ok := obj2.(*HorizontalPodAutoscaler) |  | ||||||
| 		if !ok { |  | ||||||
| 			t.Errorf("unexpected object: %v", hpa2) |  | ||||||
| 			t.FailNow() |  | ||||||
| 		} |  | ||||||
| 		if hpa2.Spec.CPUUtilization == nil { |  | ||||||
| 			t.Errorf("unexpected nil CPUUtilization") |  | ||||||
| 		} else if test.expectUtilization != hpa2.Spec.CPUUtilization.TargetPercentage { |  | ||||||
| 			t.Errorf("expected: %d CPUUtilization, got: %d", test.expectUtilization, hpa2.Spec.CPUUtilization.TargetPercentage) |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func roundTrip(t *testing.T, obj runtime.Object) runtime.Object { | func roundTrip(t *testing.T, obj runtime.Object) runtime.Object { | ||||||
| 	data, err := runtime.Encode(api.Codecs.LegacyCodec(SchemeGroupVersion), obj) | 	data, err := runtime.Encode(api.Codecs.LegacyCodec(SchemeGroupVersion), obj) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|   | |||||||
| @@ -44,8 +44,6 @@ func addKnownTypes(scheme *runtime.Scheme) error { | |||||||
| 		&Deployment{}, | 		&Deployment{}, | ||||||
| 		&DeploymentList{}, | 		&DeploymentList{}, | ||||||
| 		&DeploymentRollback{}, | 		&DeploymentRollback{}, | ||||||
| 		&HorizontalPodAutoscaler{}, |  | ||||||
| 		&HorizontalPodAutoscalerList{}, |  | ||||||
| 		&ReplicationControllerDummy{}, | 		&ReplicationControllerDummy{}, | ||||||
| 		&Scale{}, | 		&Scale{}, | ||||||
| 		&ThirdPartyResource{}, | 		&ThirdPartyResource{}, | ||||||
|   | |||||||
| @@ -73,28 +73,6 @@ type ReplicationControllerDummy struct { | |||||||
| 	metav1.TypeMeta `json:",inline"` | 	metav1.TypeMeta `json:",inline"` | ||||||
| } | } | ||||||
|  |  | ||||||
| // SubresourceReference contains enough information to let you inspect or modify the referred subresource. |  | ||||||
| type SubresourceReference struct { |  | ||||||
| 	// Kind of the referent; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds |  | ||||||
| 	// +optional |  | ||||||
| 	Kind string `json:"kind,omitempty" protobuf:"bytes,1,opt,name=kind"` |  | ||||||
| 	// Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names |  | ||||||
| 	// +optional |  | ||||||
| 	Name string `json:"name,omitempty" protobuf:"bytes,2,opt,name=name"` |  | ||||||
| 	// API version of the referent |  | ||||||
| 	// +optional |  | ||||||
| 	APIVersion string `json:"apiVersion,omitempty" protobuf:"bytes,3,opt,name=apiVersion"` |  | ||||||
| 	// Subresource name of the referent |  | ||||||
| 	// +optional |  | ||||||
| 	Subresource string `json:"subresource,omitempty" protobuf:"bytes,4,opt,name=subresource"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| type CPUTargetUtilization struct { |  | ||||||
| 	// fraction of the requested CPU that should be utilized/used, |  | ||||||
| 	// e.g. 70 means that 70% of the requested CPU should be in use. |  | ||||||
| 	TargetPercentage int32 `json:"targetPercentage" protobuf:"varint,1,opt,name=targetPercentage"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Alpha-level support for Custom Metrics in HPA (as annotations). | // Alpha-level support for Custom Metrics in HPA (as annotations). | ||||||
| type CustomMetricTarget struct { | type CustomMetricTarget struct { | ||||||
| 	// Custom Metric name. | 	// Custom Metric name. | ||||||
| @@ -118,72 +96,6 @@ type CustomMetricCurrentStatusList struct { | |||||||
| 	Items []CustomMetricCurrentStatus `json:"items" protobuf:"bytes,1,rep,name=items"` | 	Items []CustomMetricCurrentStatus `json:"items" protobuf:"bytes,1,rep,name=items"` | ||||||
| } | } | ||||||
|  |  | ||||||
| // specification of a horizontal pod autoscaler. |  | ||||||
| type HorizontalPodAutoscalerSpec struct { |  | ||||||
| 	// reference to Scale subresource; horizontal pod autoscaler will learn the current resource consumption from its status, |  | ||||||
| 	// and will set the desired number of pods by modifying its spec. |  | ||||||
| 	ScaleRef SubresourceReference `json:"scaleRef" protobuf:"bytes,1,opt,name=scaleRef"` |  | ||||||
| 	// lower limit for the number of pods that can be set by the autoscaler, default 1. |  | ||||||
| 	// +optional |  | ||||||
| 	MinReplicas *int32 `json:"minReplicas,omitempty" protobuf:"varint,2,opt,name=minReplicas"` |  | ||||||
| 	// upper limit for the number of pods that can be set by the autoscaler; cannot be smaller than MinReplicas. |  | ||||||
| 	MaxReplicas int32 `json:"maxReplicas" protobuf:"varint,3,opt,name=maxReplicas"` |  | ||||||
| 	// target average CPU utilization (represented as a percentage of requested CPU) over all the pods; |  | ||||||
| 	// if not specified it defaults to the target CPU utilization at 80% of the requested resources. |  | ||||||
| 	// +optional |  | ||||||
| 	CPUUtilization *CPUTargetUtilization `json:"cpuUtilization,omitempty" protobuf:"bytes,4,opt,name=cpuUtilization"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // current status of a horizontal pod autoscaler |  | ||||||
| type HorizontalPodAutoscalerStatus struct { |  | ||||||
| 	// most recent generation observed by this autoscaler. |  | ||||||
| 	// +optional |  | ||||||
| 	ObservedGeneration *int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"` |  | ||||||
|  |  | ||||||
| 	// last time the HorizontalPodAutoscaler scaled the number of pods; |  | ||||||
| 	// used by the autoscaler to control how often the number of pods is changed. |  | ||||||
| 	// +optional |  | ||||||
| 	LastScaleTime *metav1.Time `json:"lastScaleTime,omitempty" protobuf:"bytes,2,opt,name=lastScaleTime"` |  | ||||||
|  |  | ||||||
| 	// current number of replicas of pods managed by this autoscaler. |  | ||||||
| 	CurrentReplicas int32 `json:"currentReplicas" protobuf:"varint,3,opt,name=currentReplicas"` |  | ||||||
|  |  | ||||||
| 	// desired number of replicas of pods managed by this autoscaler. |  | ||||||
| 	DesiredReplicas int32 `json:"desiredReplicas" protobuf:"varint,4,opt,name=desiredReplicas"` |  | ||||||
|  |  | ||||||
| 	// current average CPU utilization over all pods, represented as a percentage of requested CPU, |  | ||||||
| 	// e.g. 70 means that an average pod is using now 70% of its requested CPU. |  | ||||||
| 	// +optional |  | ||||||
| 	CurrentCPUUtilizationPercentage *int32 `json:"currentCPUUtilizationPercentage,omitempty" protobuf:"varint,5,opt,name=currentCPUUtilizationPercentage"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // configuration of a horizontal pod autoscaler. |  | ||||||
| type HorizontalPodAutoscaler struct { |  | ||||||
| 	metav1.TypeMeta `json:",inline"` |  | ||||||
| 	// Standard object metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata |  | ||||||
| 	// +optional |  | ||||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |  | ||||||
|  |  | ||||||
| 	// behaviour of autoscaler. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status. |  | ||||||
| 	// +optional |  | ||||||
| 	Spec HorizontalPodAutoscalerSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` |  | ||||||
|  |  | ||||||
| 	// current information about the autoscaler. |  | ||||||
| 	// +optional |  | ||||||
| 	Status HorizontalPodAutoscalerStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // list of horizontal pod autoscaler objects. |  | ||||||
| type HorizontalPodAutoscalerList struct { |  | ||||||
| 	metav1.TypeMeta `json:",inline"` |  | ||||||
| 	// Standard list metadata. |  | ||||||
| 	// +optional |  | ||||||
| 	metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |  | ||||||
|  |  | ||||||
| 	// list of horizontal pod autoscaler objects. |  | ||||||
| 	Items []HorizontalPodAutoscaler `json:"items" protobuf:"bytes,2,rep,name=items"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // +genclient=true | // +genclient=true | ||||||
| // +nonNamespaced=true | // +nonNamespaced=true | ||||||
|  |  | ||||||
|   | |||||||
| @@ -25,26 +25,6 @@ import ( | |||||||
| 	"k8s.io/kubernetes/pkg/apis/autoscaling" | 	"k8s.io/kubernetes/pkg/apis/autoscaling" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| type HorizontalPodAutoscalerV1Beta1 struct{} |  | ||||||
|  |  | ||||||
| func (HorizontalPodAutoscalerV1Beta1) ParamNames() []GeneratorParam { |  | ||||||
| 	return []GeneratorParam{ |  | ||||||
| 		{"default-name", true}, |  | ||||||
| 		{"name", false}, |  | ||||||
| 		{"scaleRef-kind", false}, |  | ||||||
| 		{"scaleRef-name", false}, |  | ||||||
| 		{"scaleRef-apiVersion", false}, |  | ||||||
| 		{"scaleRef-subresource", false}, |  | ||||||
| 		{"min", false}, |  | ||||||
| 		{"max", true}, |  | ||||||
| 		{"cpu-percent", false}, |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (HorizontalPodAutoscalerV1Beta1) Generate(genericParams map[string]interface{}) (runtime.Object, error) { |  | ||||||
| 	return generateHPA(genericParams) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| type HorizontalPodAutoscalerV1 struct{} | type HorizontalPodAutoscalerV1 struct{} | ||||||
|  |  | ||||||
| func (HorizontalPodAutoscalerV1) ParamNames() []GeneratorParam { | func (HorizontalPodAutoscalerV1) ParamNames() []GeneratorParam { | ||||||
|   | |||||||
| @@ -397,7 +397,6 @@ func getRESTMappings(pruneResources *[]pruneResource) (namespaced, nonNamespaced | |||||||
| 			{"batch", "v1", "Job", true}, | 			{"batch", "v1", "Job", true}, | ||||||
| 			{"extensions", "v1beta1", "DaemonSet", true}, | 			{"extensions", "v1beta1", "DaemonSet", true}, | ||||||
| 			{"extensions", "v1beta1", "Deployment", true}, | 			{"extensions", "v1beta1", "Deployment", true}, | ||||||
| 			{"extensions", "v1beta1", "HorizontalPodAutoscaler", true}, |  | ||||||
| 			{"extensions", "v1beta1", "Ingress", true}, | 			{"extensions", "v1beta1", "Ingress", true}, | ||||||
| 			{"extensions", "v1beta1", "ReplicaSet", true}, | 			{"extensions", "v1beta1", "ReplicaSet", true}, | ||||||
| 			{"apps", "v1beta1", "StatefulSet", true}, | 			{"apps", "v1beta1", "StatefulSet", true}, | ||||||
|   | |||||||
| @@ -440,7 +440,6 @@ const ( | |||||||
| 	ServiceLoadBalancerGeneratorV1Name     = "service-loadbalancer/v1" | 	ServiceLoadBalancerGeneratorV1Name     = "service-loadbalancer/v1" | ||||||
| 	ServiceExternalNameGeneratorV1Name     = "service-externalname/v1" | 	ServiceExternalNameGeneratorV1Name     = "service-externalname/v1" | ||||||
| 	ServiceAccountV1GeneratorName          = "serviceaccount/v1" | 	ServiceAccountV1GeneratorName          = "serviceaccount/v1" | ||||||
| 	HorizontalPodAutoscalerV1Beta1GeneratorName = "horizontalpodautoscaler/v1beta1" |  | ||||||
| 	HorizontalPodAutoscalerV1GeneratorName = "horizontalpodautoscaler/v1" | 	HorizontalPodAutoscalerV1GeneratorName = "horizontalpodautoscaler/v1" | ||||||
| 	DeploymentV1Beta1GeneratorName         = "deployment/v1beta1" | 	DeploymentV1Beta1GeneratorName         = "deployment/v1beta1" | ||||||
| 	DeploymentBasicV1Beta1GeneratorName    = "deployment-basic/v1beta1" | 	DeploymentBasicV1Beta1GeneratorName    = "deployment-basic/v1beta1" | ||||||
| @@ -495,7 +494,6 @@ func DefaultGenerators(cmdName string) map[string]kubectl.Generator { | |||||||
| 		} | 		} | ||||||
| 	case "autoscale": | 	case "autoscale": | ||||||
| 		generator = map[string]kubectl.Generator{ | 		generator = map[string]kubectl.Generator{ | ||||||
| 			HorizontalPodAutoscalerV1Beta1GeneratorName: kubectl.HorizontalPodAutoscalerV1Beta1{}, |  | ||||||
| 			HorizontalPodAutoscalerV1GeneratorName: kubectl.HorizontalPodAutoscalerV1{}, | 			HorizontalPodAutoscalerV1GeneratorName: kubectl.HorizontalPodAutoscalerV1{}, | ||||||
| 		} | 		} | ||||||
| 	case "namespace": | 	case "namespace": | ||||||
|   | |||||||
| @@ -138,7 +138,6 @@ func describerMap(c clientset.Interface) map[schema.GroupKind]Describer { | |||||||
| 		api.Kind("ConfigMap"):             &ConfigMapDescriber{c}, | 		api.Kind("ConfigMap"):             &ConfigMapDescriber{c}, | ||||||
|  |  | ||||||
| 		extensions.Kind("ReplicaSet"):                  &ReplicaSetDescriber{c}, | 		extensions.Kind("ReplicaSet"):                  &ReplicaSetDescriber{c}, | ||||||
| 		extensions.Kind("HorizontalPodAutoscaler"):     &HorizontalPodAutoscalerDescriber{c}, |  | ||||||
| 		extensions.Kind("NetworkPolicy"):               &NetworkPolicyDescriber{c}, | 		extensions.Kind("NetworkPolicy"):               &NetworkPolicyDescriber{c}, | ||||||
| 		autoscaling.Kind("HorizontalPodAutoscaler"):    &HorizontalPodAutoscalerDescriber{c}, | 		autoscaling.Kind("HorizontalPodAutoscaler"):    &HorizontalPodAutoscalerDescriber{c}, | ||||||
| 		extensions.Kind("DaemonSet"):                   &DaemonSetDescriber{c}, | 		extensions.Kind("DaemonSet"):                   &DaemonSetDescriber{c}, | ||||||
|   | |||||||
| @@ -406,7 +406,6 @@ func DefaultAPIResourceConfigSource() *genericapiserver.ResourceConfig { | |||||||
| 	ret.EnableResources( | 	ret.EnableResources( | ||||||
| 		extensionsapiv1beta1.SchemeGroupVersion.WithResource("daemonsets"), | 		extensionsapiv1beta1.SchemeGroupVersion.WithResource("daemonsets"), | ||||||
| 		extensionsapiv1beta1.SchemeGroupVersion.WithResource("deployments"), | 		extensionsapiv1beta1.SchemeGroupVersion.WithResource("deployments"), | ||||||
| 		extensionsapiv1beta1.SchemeGroupVersion.WithResource("horizontalpodautoscalers"), |  | ||||||
| 		extensionsapiv1beta1.SchemeGroupVersion.WithResource("ingresses"), | 		extensionsapiv1beta1.SchemeGroupVersion.WithResource("ingresses"), | ||||||
| 		extensionsapiv1beta1.SchemeGroupVersion.WithResource("networkpolicies"), | 		extensionsapiv1beta1.SchemeGroupVersion.WithResource("networkpolicies"), | ||||||
| 		extensionsapiv1beta1.SchemeGroupVersion.WithResource("replicasets"), | 		extensionsapiv1beta1.SchemeGroupVersion.WithResource("replicasets"), | ||||||
|   | |||||||
| @@ -30,7 +30,6 @@ import ( | |||||||
| 	"k8s.io/kubernetes/pkg/genericapiserver/registry/generic" | 	"k8s.io/kubernetes/pkg/genericapiserver/registry/generic" | ||||||
| 	"k8s.io/kubernetes/pkg/genericapiserver/registry/rest" | 	"k8s.io/kubernetes/pkg/genericapiserver/registry/rest" | ||||||
| 	genericapiserver "k8s.io/kubernetes/pkg/genericapiserver/server" | 	genericapiserver "k8s.io/kubernetes/pkg/genericapiserver/server" | ||||||
| 	horizontalpodautoscalerstore "k8s.io/kubernetes/pkg/registry/autoscaling/horizontalpodautoscaler/storage" |  | ||||||
| 	expcontrollerstore "k8s.io/kubernetes/pkg/registry/extensions/controller/storage" | 	expcontrollerstore "k8s.io/kubernetes/pkg/registry/extensions/controller/storage" | ||||||
| 	daemonstore "k8s.io/kubernetes/pkg/registry/extensions/daemonset/storage" | 	daemonstore "k8s.io/kubernetes/pkg/registry/extensions/daemonset/storage" | ||||||
| 	deploymentstore "k8s.io/kubernetes/pkg/registry/extensions/deployment/storage" | 	deploymentstore "k8s.io/kubernetes/pkg/registry/extensions/deployment/storage" | ||||||
| @@ -61,15 +60,12 @@ func (p RESTStorageProvider) v1beta1Storage(apiResourceConfigSource genericapise | |||||||
|  |  | ||||||
| 	storage := map[string]rest.Storage{} | 	storage := map[string]rest.Storage{} | ||||||
|  |  | ||||||
| 	if apiResourceConfigSource.ResourceEnabled(version.WithResource("horizontalpodautoscalers")) { | 	// This is a dummy replication controller for scale subresource purposes. | ||||||
| 		hpaStorage, hpaStatusStorage := horizontalpodautoscalerstore.NewREST(restOptionsGetter) | 	// TODO: figure out how to enable this only if needed as a part of scale subresource GA. | ||||||
| 		storage["horizontalpodautoscalers"] = hpaStorage |  | ||||||
| 		storage["horizontalpodautoscalers/status"] = hpaStatusStorage |  | ||||||
|  |  | ||||||
| 	controllerStorage := expcontrollerstore.NewStorage(restOptionsGetter) | 	controllerStorage := expcontrollerstore.NewStorage(restOptionsGetter) | ||||||
| 	storage["replicationcontrollers"] = controllerStorage.ReplicationController | 	storage["replicationcontrollers"] = controllerStorage.ReplicationController | ||||||
| 	storage["replicationcontrollers/scale"] = controllerStorage.Scale | 	storage["replicationcontrollers/scale"] = controllerStorage.Scale | ||||||
| 	} |  | ||||||
| 	if apiResourceConfigSource.ResourceEnabled(version.WithResource("thirdpartyresources")) { | 	if apiResourceConfigSource.ResourceEnabled(version.WithResource("thirdpartyresources")) { | ||||||
| 		thirdPartyResourceStorage := thirdpartyresourcestore.NewREST(restOptionsGetter) | 		thirdPartyResourceStorage := thirdpartyresourcestore.NewREST(restOptionsGetter) | ||||||
| 		storage["thirdpartyresources"] = thirdPartyResourceStorage | 		storage["thirdpartyresources"] = thirdPartyResourceStorage | ||||||
|   | |||||||
| @@ -164,7 +164,6 @@ func TestAutoscalingGroupBackwardCompatibility(t *testing.T) { | |||||||
| 	}{ | 	}{ | ||||||
| 		{"POST", autoscalingPath("horizontalpodautoscalers", metav1.NamespaceDefault, ""), hpaV1, integration.Code201, ""}, | 		{"POST", autoscalingPath("horizontalpodautoscalers", metav1.NamespaceDefault, ""), hpaV1, integration.Code201, ""}, | ||||||
| 		{"GET", autoscalingPath("horizontalpodautoscalers", metav1.NamespaceDefault, ""), "", integration.Code200, testapi.Autoscaling.GroupVersion().String()}, | 		{"GET", autoscalingPath("horizontalpodautoscalers", metav1.NamespaceDefault, ""), "", integration.Code200, testapi.Autoscaling.GroupVersion().String()}, | ||||||
| 		{"GET", extensionsPath("horizontalpodautoscalers", metav1.NamespaceDefault, ""), "", integration.Code200, testapi.Extensions.GroupVersion().String()}, |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	for _, r := range requests { | 	for _, r := range requests { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Piotr Szczesniak
					Piotr Szczesniak