Switch the namespace controller to use the metadata client

The metadata client uses protobuf and returns only a subset of object
data (the metadata) which allows operations that act only on objects
generically to work much faster. Use the metadata client in the
namespace controller to reduce the amount of work the namespace controller
has to do in large namespaces.
This commit is contained in:
Clayton Coleman
2019-06-05 15:19:55 -04:00
parent bc89c37f32
commit 50fd47258d
10 changed files with 49 additions and 46 deletions

View File

@@ -20,9 +20,9 @@ import (
"time"
"k8s.io/api/core/v1"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/informers"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/metadata"
restclient "k8s.io/client-go/rest"
namespacecontroller "k8s.io/kubernetes/pkg/controller/namespace"
)
@@ -59,7 +59,7 @@ func (n *NamespaceController) Start() error {
if err != nil {
return err
}
dynamicClient, err := dynamic.NewForConfig(config)
metadataClient, err := metadata.NewForConfig(config)
if err != nil {
return err
}
@@ -67,7 +67,7 @@ func (n *NamespaceController) Start() error {
informerFactory := informers.NewSharedInformerFactory(client, ncResyncPeriod)
nc := namespacecontroller.NewNamespaceController(
client,
dynamicClient,
metadataClient,
discoverResourcesFn,
informerFactory.Core().V1().Namespaces(),
ncResyncPeriod, v1.FinalizerKubernetes,