Skip to content

Commit

Permalink
[feat] ability to customize kube client qps
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekTBrown committed Jan 9, 2025
1 parent 473890c commit 863e03a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"flag"

"github.com/argoproj-labs/rollouts-plugin-trafficrouter-gatewayapi/internal/utils"
"github.com/argoproj-labs/rollouts-plugin-trafficrouter-gatewayapi/pkg/plugin"

Expand All @@ -19,12 +21,24 @@ var handshakeConfig = goPlugin.HandshakeConfig{
}

func main() {
// Define and parse flags for your new command line options:
kubeClientQPS := flag.Int("kubeClientQPS", 5, "The QPS to use for the Kubernetes client.")
kubeClientBurst := flag.Int("kubeClientBurst", 10, "The Burst to use for the Kubernetes client.")
flag.Parse()

// Create the plugin implementation, injecting your command line options:
rpcPluginImp := &plugin.RpcPlugin{
CommandLineOpts: plugin.CommandLineOpts{
KubeClientQPS: float32(*kubeClientQPS),
KubeClientBurst: *kubeClientBurst,
},
LogCtx: utils.SetupLog(),
}

pluginMap := map[string]goPlugin.Plugin{
"RpcTrafficRouterPlugin": &rolloutsPlugin.RpcTrafficRouterPlugin{Impl: rpcPluginImp},
}

goPlugin.Serve(&goPlugin.ServeConfig{
HandshakeConfig: handshakeConfig,
Plugins: pluginMap,
Expand Down
6 changes: 6 additions & 0 deletions pkg/plugin/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ import (
gatewayApiClientv1alpha2 "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/typed/apis/v1alpha2"
)

type CommandLineOpts struct {
KubeClientQPS float32
KubeClientBurst int
}

type RpcPlugin struct {
CommandLineOpts CommandLineOpts
HTTPRouteClient gatewayApiClientv1.HTTPRouteInterface
TCPRouteClient gatewayApiClientv1alpha2.TCPRouteInterface
GRPCRouteClient gatewayApiClientv1.GRPCRouteInterface
Expand Down

0 comments on commit 863e03a

Please sign in to comment.