diff --git a/pkg/api/types.go b/pkg/api/types.go index 57f325d59..a03cfed91 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -108,7 +108,7 @@ var SupportedGroupVersionResources = map[ClientType][]schema.GroupVersionResourc {Group: "networking.k8s.io", Version: "v1", Resource: "ingresses"}, - {Group: "autoscaling", Version: "v2beta2", Resource: "horizontalpodautoscalers"}, + {Group: "autoscaling", Version: "v2", Resource: "horizontalpodautoscalers"}, }, // all supported kubesphere api objects diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index bbc1efd47..bea9c958a 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -466,7 +466,7 @@ func (s *APIServer) waitForResourceSync(ctx context.Context) error { "ingresses", "networkpolicies", }, - {Group: "autoscaling", Version: "v2beta2"}: { + {Group: "autoscaling", Version: "v2"}: { "horizontalpodautoscalers", }, } diff --git a/pkg/models/resources/v1alpha2/hpa/horizontalpodautoscalers.go b/pkg/models/resources/v1alpha2/hpa/horizontalpodautoscalers.go index a082680a8..a5f018115 100644 --- a/pkg/models/resources/v1alpha2/hpa/horizontalpodautoscalers.go +++ b/pkg/models/resources/v1alpha2/hpa/horizontalpodautoscalers.go @@ -18,7 +18,7 @@ package hpa import ( "sort" - autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2" + autoscalingv2 "k8s.io/api/autoscaling/v2" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/informers" @@ -35,15 +35,15 @@ func NewHpaSearcher(informers informers.SharedInformerFactory) v1alpha2.Interfac } func (s *hpaSearcher) Get(namespace, name string) (interface{}, error) { - return s.informers.Autoscaling().V2beta2().HorizontalPodAutoscalers().Lister().HorizontalPodAutoscalers(namespace).Get(name) + return s.informers.Autoscaling().V2().HorizontalPodAutoscalers().Lister().HorizontalPodAutoscalers(namespace).Get(name) } -func hpaTargetMatch(item *autoscalingv2beta2.HorizontalPodAutoscaler, kind, name string) bool { +func hpaTargetMatch(item *autoscalingv2.HorizontalPodAutoscaler, kind, name string) bool { return item.Spec.ScaleTargetRef.Kind == kind && item.Spec.ScaleTargetRef.Name == name } // exactly Match -func (*hpaSearcher) match(match map[string]string, item *autoscalingv2beta2.HorizontalPodAutoscaler) bool { +func (*hpaSearcher) match(match map[string]string, item *autoscalingv2.HorizontalPodAutoscaler) bool { for k, v := range match { switch k { case v1alpha2.TargetKind: @@ -63,7 +63,7 @@ func (*hpaSearcher) match(match map[string]string, item *autoscalingv2beta2.Hori return true } -func (*hpaSearcher) fuzzy(fuzzy map[string]string, item *autoscalingv2beta2.HorizontalPodAutoscaler) bool { +func (*hpaSearcher) fuzzy(fuzzy map[string]string, item *autoscalingv2.HorizontalPodAutoscaler) bool { for k, v := range fuzzy { if !v1alpha2.ObjectMetaFuzzyMath(k, v, item.ObjectMeta) { return false @@ -74,13 +74,13 @@ func (*hpaSearcher) fuzzy(fuzzy map[string]string, item *autoscalingv2beta2.Hori func (s *hpaSearcher) Search(namespace string, conditions *params.Conditions, orderBy string, reverse bool) ([]interface{}, error) { - horizontalPodAutoscalers, err := s.informers.Autoscaling().V2beta2().HorizontalPodAutoscalers().Lister().HorizontalPodAutoscalers(namespace).List(labels.Everything()) + horizontalPodAutoscalers, err := s.informers.Autoscaling().V2().HorizontalPodAutoscalers().Lister().HorizontalPodAutoscalers(namespace).List(labels.Everything()) if err != nil { return nil, err } - result := make([]*autoscalingv2beta2.HorizontalPodAutoscaler, 0) + result := make([]*autoscalingv2.HorizontalPodAutoscaler, 0) if len(conditions.Match) == 0 && len(conditions.Fuzzy) == 0 { result = horizontalPodAutoscalers