Skip to content

Commit

Permalink
use proto on client go to improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
aojea committed Apr 27, 2024
1 parent 08f7faa commit 3b9245d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
Expand Down

0 comments on commit 3b9245d

Please sign in to comment.