Skip to content

Commit

Permalink
controller-manager: namespace-controller should use protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
vrutkovs committed Oct 23, 2024
1 parent faaab1b commit 8a10675
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion cmd/kube-controller-manager/app/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
utilfeature "k8s.io/apiserver/pkg/util/feature"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/metadata"
"k8s.io/client-go/rest"
restclient "k8s.io/client-go/rest"
cloudnodelifecyclecontroller "k8s.io/cloud-provider/controllers/nodelifecycle"
routecontroller "k8s.io/cloud-provider/controllers/route"
Expand Down Expand Up @@ -589,7 +590,12 @@ func startNamespaceController(ctx context.Context, controllerContext ControllerC
nsKubeconfig := controllerContext.ClientBuilder.ConfigOrDie("namespace-controller")
nsKubeconfig.QPS *= 20
nsKubeconfig.Burst *= 100
namespaceKubeClient := clientset.NewForConfigOrDie(nsKubeconfig)

// Use protobuf
config := rest.CopyConfig(nsKubeconfig)
config.AcceptContentTypes = "application/vnd.kubernetes.protobuf,application/json"
config.ContentType = "application/vnd.kubernetes.protobuf"
namespaceKubeClient := clientset.NewForConfigOrDie(config)
return startModifiedNamespaceController(ctx, controllerContext, namespaceKubeClient, nsKubeconfig)
}

Expand Down
5 changes: 4 additions & 1 deletion cmd/kube-controller-manager/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,10 @@ func (s KubeControllerManagerOptions) Config(allControllers []string, disabledBy
kubeconfig.Wrap(customOpenShiftRoundTripper)
}

client, err := clientset.NewForConfig(restclient.AddUserAgent(kubeconfig, KubeControllerManagerUserAgent))
protobufConfig := restclient.CopyConfig(kubeconfig)
protobufConfig.AcceptContentTypes = "application/vnd.kubernetes.protobuf,application/json"
protobufConfig.ContentType = "application/vnd.kubernetes.protobuf"
client, err := clientset.NewForConfig(restclient.AddUserAgent(protobufConfig, KubeControllerManagerUserAgent))
if err != nil {
return nil, err
}
Expand Down
6 changes: 5 additions & 1 deletion cmd/kube-controller-manager/app/patch_informers_openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ type combinedInformers struct {
}

func newInformerFactory(clientConfig *rest.Config) (informers.SharedInformerFactory, error) {
kubeClient, err := kubernetes.NewForConfig(clientConfig)
protobufConfig := rest.CopyConfig(clientConfig)
protobufConfig.AcceptContentTypes = "application/vnd.kubernetes.protobuf,application/json"
protobufConfig.ContentType = "application/vnd.kubernetes.protobuf"

kubeClient, err := kubernetes.NewForConfig(protobufConfig)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 8a10675

Please sign in to comment.