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

[feat] ability to customize kube client qps #101

Merged
Merged
Show file tree
Hide file tree
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
16 changes: 16 additions & 0 deletions docs/features/cli-options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# CLI Options

## Increasing Kubernetes API Server Request QPS and Burst
The `kubeClientQPS` and `kubeClientBurst` options configure the behavior of the Kubernetes client. These
values may need to be increased if you operate Argo Rollouts in a large cluster. These values can be specified
using the `args` block of the plugin configuration:

```yaml
trafficRouterPlugins:
trafficRouterPlugins: |-
- name: "argoproj-labs/gatewayAPI"
location: "https://github.com/argoproj-labs/rollouts-plugin-trafficrouter-gatewayapi/releases/download/v0.4.0/gatewayapi-plugin-linux-amd64"
args:
- "-kubeClientQPS=40"
- "-kubeClientBurst=80"
```
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 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 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
18 changes: 16 additions & 2 deletions pkg/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"encoding/json"
"fmt"

"github.com/argoproj-labs/rollouts-plugin-trafficrouter-gatewayapi/internal/defaults"
"github.com/argoproj-labs/rollouts-plugin-trafficrouter-gatewayapi/internal/utils"
"github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1"
pluginTypes "github.com/argoproj/argo-rollouts/utils/plugin/types"
"github.com/go-playground/validator/v10"
"k8s.io/client-go/kubernetes"
gatewayApiClientset "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned"

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

const (
Expand All @@ -19,6 +20,8 @@ const (
)

func (r *RpcPlugin) InitPlugin() pluginTypes.RpcError {
log := utils.SetupLog()

if r.IsTest {
return pluginTypes.RpcError{}
}
Expand All @@ -28,6 +31,17 @@ func (r *RpcPlugin) InitPlugin() pluginTypes.RpcError {
ErrorString: err.Error(),
}
}

// Configure command-line overrides for the Kubernetes client:
if r.CommandLineOpts.KubeClientQPS != 0 {
log.Infof("KubeClientQPS set to: %f", r.CommandLineOpts.KubeClientQPS)
kubeConfig.QPS = r.CommandLineOpts.KubeClientQPS
}
if r.CommandLineOpts.KubeClientBurst != 0 {
log.Infof("KubeClientBurst set to: %d", r.CommandLineOpts.KubeClientBurst)
kubeConfig.Burst = r.CommandLineOpts.KubeClientBurst
}

gatewayAPIClientset, err := gatewayApiClientset.NewForConfig(kubeConfig)
if err != nil {
return pluginTypes.RpcError{
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
Loading