From b2ef27f146db784a4f5f1e866cd2594648bc4c9e Mon Sep 17 00:00:00 2001 From: Nikhil-Ladha Date: Wed, 18 Sep 2024 13:47:34 +0530 Subject: [PATCH] Use protobuf encoding for core K8s apis For core K8s API objects like Pods, Nodes, etc., we can use protobuf encoding which reduces CPU consumption related to (de)serialization, reduces overall latency of the API call, reduces memory footprint, reduces the amount of work performed by the GC and results in quicker propagation of objects to event handlers of shared informers. Signed-off-by: Nikhil-Ladha --- cmd/csi-addons/main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/csi-addons/main.go b/cmd/csi-addons/main.go index c2a3e769f..ddc3a11cf 100644 --- a/cmd/csi-addons/main.go +++ b/cmd/csi-addons/main.go @@ -25,6 +25,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" ) @@ -122,6 +123,8 @@ func getKubernetesClient() *kubernetes.Clientset { panic(err.Error()) } + config.ContentType = runtime.ContentTypeProtobuf + clientset, err := kubernetes.NewForConfig(config) if err != nil { panic(err.Error())