Use autoscaling/v2 instead of autoscaling/v2beta2 (#5833)
This commit is contained in:
@@ -108,7 +108,7 @@ var SupportedGroupVersionResources = map[ClientType][]schema.GroupVersionResourc
|
|||||||
|
|
||||||
{Group: "networking.k8s.io", Version: "v1", Resource: "ingresses"},
|
{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
|
// all supported kubesphere api objects
|
||||||
|
|||||||
@@ -466,7 +466,7 @@ func (s *APIServer) waitForResourceSync(ctx context.Context) error {
|
|||||||
"ingresses",
|
"ingresses",
|
||||||
"networkpolicies",
|
"networkpolicies",
|
||||||
},
|
},
|
||||||
{Group: "autoscaling", Version: "v2beta2"}: {
|
{Group: "autoscaling", Version: "v2"}: {
|
||||||
"horizontalpodautoscalers",
|
"horizontalpodautoscalers",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package hpa
|
|||||||
import (
|
import (
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2"
|
autoscalingv2 "k8s.io/api/autoscaling/v2"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/client-go/informers"
|
"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) {
|
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
|
return item.Spec.ScaleTargetRef.Kind == kind && item.Spec.ScaleTargetRef.Name == name
|
||||||
}
|
}
|
||||||
|
|
||||||
// exactly Match
|
// 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 {
|
for k, v := range match {
|
||||||
switch k {
|
switch k {
|
||||||
case v1alpha2.TargetKind:
|
case v1alpha2.TargetKind:
|
||||||
@@ -63,7 +63,7 @@ func (*hpaSearcher) match(match map[string]string, item *autoscalingv2beta2.Hori
|
|||||||
return true
|
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 {
|
for k, v := range fuzzy {
|
||||||
if !v1alpha2.ObjectMetaFuzzyMath(k, v, item.ObjectMeta) {
|
if !v1alpha2.ObjectMetaFuzzyMath(k, v, item.ObjectMeta) {
|
||||||
return false
|
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) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result := make([]*autoscalingv2beta2.HorizontalPodAutoscaler, 0)
|
result := make([]*autoscalingv2.HorizontalPodAutoscaler, 0)
|
||||||
|
|
||||||
if len(conditions.Match) == 0 && len(conditions.Fuzzy) == 0 {
|
if len(conditions.Match) == 0 && len(conditions.Fuzzy) == 0 {
|
||||||
result = horizontalPodAutoscalers
|
result = horizontalPodAutoscalers
|
||||||
|
|||||||
Reference in New Issue
Block a user