From 3b9245d762d61806a07b00b17aa588d5f07dd604 Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Sat, 27 Apr 2024 11:20:15 +0000 Subject: [PATCH] use proto on client go to improve performance --- cmd/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/main.go b/cmd/main.go index 7f81e87..ed1f60c 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -75,6 +75,13 @@ func main() { if err != nil { panic(err.Error()) } + + // use protobuf for better performance at scale + // https://kubernetes.io/docs/reference/using-api/api-concepts/#alternate-representations-of-resources + npaConfig := config // shallow copy because CRDs does not support proto + config.AcceptContentTypes = "application/vnd.kubernetes.protobuf,application/json" + config.ContentType = "application/vnd.kubernetes.protobuf" + // creates the clientset clientset, err := kubernetes.NewForConfig(config) if err != nil { @@ -100,7 +107,7 @@ func main() { var nodeInformer v1.NodeInformer if adminNetworkPolicy || baselineAdminNetworkPolicy { nodeInformer = informersFactory.Core().V1().Nodes() - npaClient, err = npaclient.NewForConfig(config) + npaClient, err = npaclient.NewForConfig(npaConfig) if err != nil { klog.Fatalf("Failed to create Network client: %v", err) }