Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use proto on client go to improve performance #19

Merged
merged 1 commit into from
Apr 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading