From a35ad8f6ba7896121790692c1ad232bdd5578e82 Mon Sep 17 00:00:00 2001 From: Piotr Szczesniak Date: Thu, 5 Jan 2017 14:16:52 +0100 Subject: [PATCH] Removed HPA objects from extensions api group --- cmd/kube-apiserver/app/server.go | 3 - hack/make-rules/test-cmd-util.sh | 14 +-- hack/test-update-storage-objects.sh | 11 +-- pkg/api/defaulting_test.go | 2 - pkg/apis/extensions/register.go | 3 - pkg/apis/extensions/v1beta1/conversion.go | 56 ------------ pkg/apis/extensions/v1beta1/defaults.go | 11 --- pkg/apis/extensions/v1beta1/defaults_test.go | 72 --------------- pkg/apis/extensions/v1beta1/register.go | 2 - pkg/apis/extensions/v1beta1/types.go | 88 ------------------- pkg/kubectl/autoscale.go | 20 ----- pkg/kubectl/cmd/apply.go | 1 - pkg/kubectl/cmd/util/factory_client_access.go | 54 ++++++------ pkg/kubectl/describe.go | 1 - pkg/master/master.go | 1 - .../extensions/rest/storage_extensions.go | 14 ++- test/integration/master/master_test.go | 1 - 17 files changed, 39 insertions(+), 315 deletions(-) diff --git a/cmd/kube-apiserver/app/server.go b/cmd/kube-apiserver/app/server.go index 13bd884fd53..2a569072258 100644 --- a/cmd/kube-apiserver/app/server.go +++ b/cmd/kube-apiserver/app/server.go @@ -44,9 +44,7 @@ import ( "k8s.io/apiserver/pkg/server/filters" "k8s.io/kubernetes/cmd/kube-apiserver/app/options" "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/autoscaling" "k8s.io/kubernetes/pkg/apis/batch" - "k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/capabilities" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" "k8s.io/kubernetes/pkg/cloudprovider" @@ -202,7 +200,6 @@ func Run(s *options.ServerRunOptions) error { if err != nil { return fmt.Errorf("error in initializing storage factory: %s", err) } - storageFactory.AddCohabitatingResources(autoscaling.Resource("horizontalpodautoscalers"), extensions.Resource("horizontalpodautoscalers")) for _, override := range s.Etcd.EtcdServersOverrides { tokens := strings.Split(override, "#") if len(tokens) != 2 { diff --git a/hack/make-rules/test-cmd-util.sh b/hack/make-rules/test-cmd-util.sh index 3c19baf772a..403c03d2012 100644 --- a/hack/make-rules/test-cmd-util.sh +++ b/hack/make-rules/test-cmd-util.sh @@ -1015,12 +1015,10 @@ run_save_config_tests() { # Command: autoscale rc "frontend" kubectl autoscale -f hack/testdata/frontend-controller.yaml --save-config "${kube_flags[@]}" --max=2 # Post-Condition: hpa "frontend" has configuration annotation - [[ "$(kubectl get hpa.v1beta1.extensions 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 + [[ "$(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 autoscaling/v1 APIs output_message=$(kubectl get hpa -o=jsonpath='{.items[0].apiVersion}' 2>&1 "${kube_flags[@]}") 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[@]}") kube::test::if_has_string "${output_message}" 'autoscaling/v1' # 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 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 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 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 ' 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 ' - kubectl delete hpa frontend "${kube_flags[@]}" # autoscale without specifying --max should fail ! kubectl autoscale rc frontend "${kube_flags[@]}" # Clean up diff --git a/hack/test-update-storage-objects.sh b/hack/test-update-storage-objects.sh index 7b6a939430c..bc02d900141 100755 --- a/hack/test-update-storage-objects.sh +++ b/hack/test-update-storage-objects.sh @@ -107,16 +107,17 @@ echo "${ETCD_VERSION}/${STORAGE_BACKEND_ETCD2}" > "${ETCD_DIR}/version.txt" ### 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 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_NEW_API_VERSION="v1,extensions/v1beta1,autoscaling/v1" -KUBE_OLD_STORAGE_VERSIONS="autoscaling=extensions/v1beta1" -KUBE_NEW_STORAGE_VERSIONS="autoscaling/v1" +KUBE_NEW_API_VERSION="v1,extensions/v1beta1" +KUBE_OLD_STORAGE_VERSIONS="v1" +KUBE_NEW_STORAGE_VERSIONS="v1" ### END TEST DEFINITION CUSTOMIZATION ### diff --git a/pkg/api/defaulting_test.go b/pkg/api/defaulting_test.go index 65d576e9604..c066d5030b0 100644 --- a/pkg/api/defaulting_test.go +++ b/pkg/api/defaulting_test.go @@ -104,8 +104,6 @@ func TestDefaulting(t *testing.T) { {Group: "extensions", Version: "v1beta1", Kind: "DaemonSetList"}: {}, {Group: "extensions", Version: "v1beta1", Kind: "Deployment"}: {}, {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: "ReplicaSetList"}: {}, {Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Kind: "ClusterRoleBinding"}: {}, diff --git a/pkg/apis/extensions/register.go b/pkg/apis/extensions/register.go index 192addffe97..5983636c225 100644 --- a/pkg/apis/extensions/register.go +++ b/pkg/apis/extensions/register.go @@ -19,7 +19,6 @@ package extensions import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/kubernetes/pkg/apis/autoscaling" ) // GroupName is the group name use in this package @@ -50,8 +49,6 @@ func addKnownTypes(scheme *runtime.Scheme) error { &Deployment{}, &DeploymentList{}, &DeploymentRollback{}, - &autoscaling.HorizontalPodAutoscaler{}, - &autoscaling.HorizontalPodAutoscalerList{}, &ReplicationControllerDummy{}, &Scale{}, &ThirdPartyResource{}, diff --git a/pkg/apis/extensions/v1beta1/conversion.go b/pkg/apis/extensions/v1beta1/conversion.go index 81d44c3e36a..2c89c1d13cd 100644 --- a/pkg/apis/extensions/v1beta1/conversion.go +++ b/pkg/apis/extensions/v1beta1/conversion.go @@ -25,7 +25,6 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/kubernetes/pkg/api" v1 "k8s.io/kubernetes/pkg/api/v1" - "k8s.io/kubernetes/pkg/apis/autoscaling" "k8s.io/kubernetes/pkg/apis/extensions" ) @@ -42,11 +41,6 @@ func addConversionFuncs(scheme *runtime.Scheme) error { Convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment, Convert_extensions_ReplicaSetSpec_To_v1beta1_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 { return err @@ -248,53 +242,3 @@ func Convert_v1beta1_ReplicaSetSpec_To_extensions_ReplicaSetSpec(in *ReplicaSetS } 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 -} diff --git a/pkg/apis/extensions/v1beta1/defaults.go b/pkg/apis/extensions/v1beta1/defaults.go index e866177c1b6..a78c17ee745 100644 --- a/pkg/apis/extensions/v1beta1/defaults.go +++ b/pkg/apis/extensions/v1beta1/defaults.go @@ -28,7 +28,6 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error { return scheme.AddDefaultingFuncs( SetDefaults_DaemonSet, SetDefaults_Deployment, - SetDefaults_HorizontalPodAutoscaler, SetDefaults_ReplicaSet, 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) { labels := obj.Spec.Template.Labels diff --git a/pkg/apis/extensions/v1beta1/defaults_test.go b/pkg/apis/extensions/v1beta1/defaults_test.go index 9b54d85694e..e8149be3adb 100644 --- a/pkg/apis/extensions/v1beta1/defaults_test.go +++ b/pkg/apis/extensions/v1beta1/defaults_test.go @@ -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 { data, err := runtime.Encode(api.Codecs.LegacyCodec(SchemeGroupVersion), obj) if err != nil { diff --git a/pkg/apis/extensions/v1beta1/register.go b/pkg/apis/extensions/v1beta1/register.go index 6b03fb02678..fa5b2e1b24d 100644 --- a/pkg/apis/extensions/v1beta1/register.go +++ b/pkg/apis/extensions/v1beta1/register.go @@ -44,8 +44,6 @@ func addKnownTypes(scheme *runtime.Scheme) error { &Deployment{}, &DeploymentList{}, &DeploymentRollback{}, - &HorizontalPodAutoscaler{}, - &HorizontalPodAutoscalerList{}, &ReplicationControllerDummy{}, &Scale{}, &ThirdPartyResource{}, diff --git a/pkg/apis/extensions/v1beta1/types.go b/pkg/apis/extensions/v1beta1/types.go index 2fa536391c3..13b4d934287 100644 --- a/pkg/apis/extensions/v1beta1/types.go +++ b/pkg/apis/extensions/v1beta1/types.go @@ -73,28 +73,6 @@ type ReplicationControllerDummy struct { 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). type CustomMetricTarget struct { // Custom Metric name. @@ -118,72 +96,6 @@ type CustomMetricCurrentStatusList struct { 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 // +nonNamespaced=true diff --git a/pkg/kubectl/autoscale.go b/pkg/kubectl/autoscale.go index e452d6428e2..a23fc56d702 100644 --- a/pkg/kubectl/autoscale.go +++ b/pkg/kubectl/autoscale.go @@ -25,26 +25,6 @@ import ( "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{} func (HorizontalPodAutoscalerV1) ParamNames() []GeneratorParam { diff --git a/pkg/kubectl/cmd/apply.go b/pkg/kubectl/cmd/apply.go index bcfa4f5df89..68d7e6a1b85 100644 --- a/pkg/kubectl/cmd/apply.go +++ b/pkg/kubectl/cmd/apply.go @@ -397,7 +397,6 @@ func getRESTMappings(pruneResources *[]pruneResource) (namespaced, nonNamespaced {"batch", "v1", "Job", true}, {"extensions", "v1beta1", "DaemonSet", true}, {"extensions", "v1beta1", "Deployment", true}, - {"extensions", "v1beta1", "HorizontalPodAutoscaler", true}, {"extensions", "v1beta1", "Ingress", true}, {"extensions", "v1beta1", "ReplicaSet", true}, {"apps", "v1beta1", "StatefulSet", true}, diff --git a/pkg/kubectl/cmd/util/factory_client_access.go b/pkg/kubectl/cmd/util/factory_client_access.go index 3dd42c458e4..4c271c8ace2 100644 --- a/pkg/kubectl/cmd/util/factory_client_access.go +++ b/pkg/kubectl/cmd/util/factory_client_access.go @@ -431,32 +431,31 @@ func (f *ring0Factory) DefaultNamespace() (string, bool, error) { } const ( - RunV1GeneratorName = "run/v1" - RunPodV1GeneratorName = "run-pod/v1" - ServiceV1GeneratorName = "service/v1" - ServiceV2GeneratorName = "service/v2" - ServiceNodePortGeneratorV1Name = "service-nodeport/v1" - ServiceClusterIPGeneratorV1Name = "service-clusterip/v1" - ServiceLoadBalancerGeneratorV1Name = "service-loadbalancer/v1" - ServiceExternalNameGeneratorV1Name = "service-externalname/v1" - ServiceAccountV1GeneratorName = "serviceaccount/v1" - HorizontalPodAutoscalerV1Beta1GeneratorName = "horizontalpodautoscaler/v1beta1" - HorizontalPodAutoscalerV1GeneratorName = "horizontalpodautoscaler/v1" - DeploymentV1Beta1GeneratorName = "deployment/v1beta1" - DeploymentBasicV1Beta1GeneratorName = "deployment-basic/v1beta1" - JobV1GeneratorName = "job/v1" - CronJobV2Alpha1GeneratorName = "cronjob/v2alpha1" - ScheduledJobV2Alpha1GeneratorName = "scheduledjob/v2alpha1" - NamespaceV1GeneratorName = "namespace/v1" - ResourceQuotaV1GeneratorName = "resourcequotas/v1" - SecretV1GeneratorName = "secret/v1" - SecretForDockerRegistryV1GeneratorName = "secret-for-docker-registry/v1" - SecretForTLSV1GeneratorName = "secret-for-tls/v1" - ConfigMapV1GeneratorName = "configmap/v1" - ClusterRoleBindingV1GeneratorName = "clusterrolebinding.rbac.authorization.k8s.io/v1alpha1" - RoleBindingV1GeneratorName = "rolebinding.rbac.authorization.k8s.io/v1alpha1" - ClusterV1Beta1GeneratorName = "cluster/v1beta1" - PodDisruptionBudgetV1GeneratorName = "poddisruptionbudget/v1beta1" + RunV1GeneratorName = "run/v1" + RunPodV1GeneratorName = "run-pod/v1" + ServiceV1GeneratorName = "service/v1" + ServiceV2GeneratorName = "service/v2" + ServiceNodePortGeneratorV1Name = "service-nodeport/v1" + ServiceClusterIPGeneratorV1Name = "service-clusterip/v1" + ServiceLoadBalancerGeneratorV1Name = "service-loadbalancer/v1" + ServiceExternalNameGeneratorV1Name = "service-externalname/v1" + ServiceAccountV1GeneratorName = "serviceaccount/v1" + HorizontalPodAutoscalerV1GeneratorName = "horizontalpodautoscaler/v1" + DeploymentV1Beta1GeneratorName = "deployment/v1beta1" + DeploymentBasicV1Beta1GeneratorName = "deployment-basic/v1beta1" + JobV1GeneratorName = "job/v1" + CronJobV2Alpha1GeneratorName = "cronjob/v2alpha1" + ScheduledJobV2Alpha1GeneratorName = "scheduledjob/v2alpha1" + NamespaceV1GeneratorName = "namespace/v1" + ResourceQuotaV1GeneratorName = "resourcequotas/v1" + SecretV1GeneratorName = "secret/v1" + SecretForDockerRegistryV1GeneratorName = "secret-for-docker-registry/v1" + SecretForTLSV1GeneratorName = "secret-for-tls/v1" + ConfigMapV1GeneratorName = "configmap/v1" + ClusterRoleBindingV1GeneratorName = "clusterrolebinding.rbac.authorization.k8s.io/v1alpha1" + RoleBindingV1GeneratorName = "rolebinding.rbac.authorization.k8s.io/v1alpha1" + ClusterV1Beta1GeneratorName = "cluster/v1beta1" + PodDisruptionBudgetV1GeneratorName = "poddisruptionbudget/v1beta1" ) // DefaultGenerators returns the set of default generators for use in Factory instances @@ -495,8 +494,7 @@ func DefaultGenerators(cmdName string) map[string]kubectl.Generator { } case "autoscale": generator = map[string]kubectl.Generator{ - HorizontalPodAutoscalerV1Beta1GeneratorName: kubectl.HorizontalPodAutoscalerV1Beta1{}, - HorizontalPodAutoscalerV1GeneratorName: kubectl.HorizontalPodAutoscalerV1{}, + HorizontalPodAutoscalerV1GeneratorName: kubectl.HorizontalPodAutoscalerV1{}, } case "namespace": generator = map[string]kubectl.Generator{ diff --git a/pkg/kubectl/describe.go b/pkg/kubectl/describe.go index 6cf94d1a71e..aa85e1e0208 100644 --- a/pkg/kubectl/describe.go +++ b/pkg/kubectl/describe.go @@ -138,7 +138,6 @@ func describerMap(c clientset.Interface) map[schema.GroupKind]Describer { api.Kind("ConfigMap"): &ConfigMapDescriber{c}, extensions.Kind("ReplicaSet"): &ReplicaSetDescriber{c}, - extensions.Kind("HorizontalPodAutoscaler"): &HorizontalPodAutoscalerDescriber{c}, extensions.Kind("NetworkPolicy"): &NetworkPolicyDescriber{c}, autoscaling.Kind("HorizontalPodAutoscaler"): &HorizontalPodAutoscalerDescriber{c}, extensions.Kind("DaemonSet"): &DaemonSetDescriber{c}, diff --git a/pkg/master/master.go b/pkg/master/master.go index d0ded1e672f..7a7a4bbf97b 100644 --- a/pkg/master/master.go +++ b/pkg/master/master.go @@ -406,7 +406,6 @@ func DefaultAPIResourceConfigSource() *genericapiserver.ResourceConfig { ret.EnableResources( extensionsapiv1beta1.SchemeGroupVersion.WithResource("daemonsets"), extensionsapiv1beta1.SchemeGroupVersion.WithResource("deployments"), - extensionsapiv1beta1.SchemeGroupVersion.WithResource("horizontalpodautoscalers"), extensionsapiv1beta1.SchemeGroupVersion.WithResource("ingresses"), extensionsapiv1beta1.SchemeGroupVersion.WithResource("networkpolicies"), extensionsapiv1beta1.SchemeGroupVersion.WithResource("replicasets"), diff --git a/pkg/registry/extensions/rest/storage_extensions.go b/pkg/registry/extensions/rest/storage_extensions.go index 21c92517f6b..3f1b5768eab 100644 --- a/pkg/registry/extensions/rest/storage_extensions.go +++ b/pkg/registry/extensions/rest/storage_extensions.go @@ -30,7 +30,6 @@ import ( "k8s.io/kubernetes/pkg/genericapiserver/registry/generic" "k8s.io/kubernetes/pkg/genericapiserver/registry/rest" 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" daemonstore "k8s.io/kubernetes/pkg/registry/extensions/daemonset/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{} - if apiResourceConfigSource.ResourceEnabled(version.WithResource("horizontalpodautoscalers")) { - hpaStorage, hpaStatusStorage := horizontalpodautoscalerstore.NewREST(restOptionsGetter) - storage["horizontalpodautoscalers"] = hpaStorage - storage["horizontalpodautoscalers/status"] = hpaStatusStorage + // This is a dummy replication controller for scale subresource purposes. + // TODO: figure out how to enable this only if needed as a part of scale subresource GA. + controllerStorage := expcontrollerstore.NewStorage(restOptionsGetter) + storage["replicationcontrollers"] = controllerStorage.ReplicationController + storage["replicationcontrollers/scale"] = controllerStorage.Scale - controllerStorage := expcontrollerstore.NewStorage(restOptionsGetter) - storage["replicationcontrollers"] = controllerStorage.ReplicationController - storage["replicationcontrollers/scale"] = controllerStorage.Scale - } if apiResourceConfigSource.ResourceEnabled(version.WithResource("thirdpartyresources")) { thirdPartyResourceStorage := thirdpartyresourcestore.NewREST(restOptionsGetter) storage["thirdpartyresources"] = thirdPartyResourceStorage diff --git a/test/integration/master/master_test.go b/test/integration/master/master_test.go index 63aded0e4cb..f839d6906d2 100644 --- a/test/integration/master/master_test.go +++ b/test/integration/master/master_test.go @@ -164,7 +164,6 @@ func TestAutoscalingGroupBackwardCompatibility(t *testing.T) { }{ {"POST", autoscalingPath("horizontalpodautoscalers", metav1.NamespaceDefault, ""), hpaV1, integration.Code201, ""}, {"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 {