Skip to content

Commit

Permalink
Update informers
Browse files Browse the repository at this point in the history
  • Loading branch information
CatherineF-dev committed Apr 24, 2024
1 parent f8c46ca commit f40432d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions custom-metrics-stackdriver-adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ import (
coreclient "k8s.io/client-go/kubernetes/typed/core/v1"
"sigs.k8s.io/custom-metrics-apiserver/pkg/provider"

"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/component-base/logs"
"k8s.io/klog"
"sigs.k8s.io/metrics-server/pkg/api"

coreadapter "github.com/GoogleCloudPlatform/k8s-stackdriver/custom-metrics-stackdriver-adapter/pkg/adapter/coreprovider"
adapter "github.com/GoogleCloudPlatform/k8s-stackdriver/custom-metrics-stackdriver-adapter/pkg/adapter/provider"
corev1 "k8s.io/api/core/v1"
basecmd "sigs.k8s.io/custom-metrics-apiserver/pkg/cmd"
)

Expand Down Expand Up @@ -144,12 +146,16 @@ func (sa *StackdriverAdapter) withCoreMetrics(translator *translator.Translator)
return err
}

pods := informers.Core().V1().Pods()
nodes := informers.Core().V1().Nodes()
if err := api.Install(provider, pods.Lister(), nodes.Lister(), server.GenericAPIServer); err != nil {
podInformer, nil := informers.ForResource(corev1.SchemeGroupVersion.WithResource("pods"))
if err != nil {
return err
}

nodes := informers.Core().V1().Nodes()
if err := api.Install(provider, podInformer.Lister(), nodes.Lister(), server.GenericAPIServer, []labels.Requirement{}); err != nil {
return nil
}

return nil
}

Expand Down

0 comments on commit f40432d

Please sign in to comment.