Skip to content

Commit 44ab8fd

Browse files
authored
[feat] ability to customize kube client qps (#101)
* [feat] ability to customize kube client qps Signed-off-by: Derek Brown <6845676+DerekTBrown@users.noreply.github.com> * fix log line type Signed-off-by: Derek Brown <6845676+DerekTBrown@users.noreply.github.com> --------- Signed-off-by: Derek Brown <6845676+DerekTBrown@users.noreply.github.com>
1 parent c6c5291 commit 44ab8fd

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed

docs/features/cli-options.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# CLI Options
2+
3+
## Increasing Kubernetes API Server Request QPS and Burst
4+
The `kubeClientQPS` and `kubeClientBurst` options configure the behavior of the Kubernetes client. These
5+
values may need to be increased if you operate Argo Rollouts in a large cluster. These values can be specified
6+
using the `args` block of the plugin configuration:
7+
8+
```yaml
9+
trafficRouterPlugins:
10+
trafficRouterPlugins: |-
11+
- name: "argoproj-labs/gatewayAPI"
12+
location: "https://github.com/argoproj-labs/rollouts-plugin-trafficrouter-gatewayapi/releases/download/v0.4.0/gatewayapi-plugin-linux-amd64"
13+
args:
14+
- "-kubeClientQPS=40"
15+
- "-kubeClientBurst=80"
16+
```

main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package main
22

33
import (
4+
"flag"
5+
46
"github.com/argoproj-labs/rollouts-plugin-trafficrouter-gatewayapi/internal/utils"
57
"github.com/argoproj-labs/rollouts-plugin-trafficrouter-gatewayapi/pkg/plugin"
68

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

2123
func main() {
24+
// Define and parse flags for your command line options:
25+
kubeClientQPS := flag.Int("kubeClientQPS", 5, "The QPS to use for the Kubernetes client.")
26+
kubeClientBurst := flag.Int("kubeClientBurst", 10, "The Burst to use for the Kubernetes client.")
27+
flag.Parse()
28+
29+
// Create the plugin implementation, injecting command line options:
2230
rpcPluginImp := &plugin.RpcPlugin{
31+
CommandLineOpts: plugin.CommandLineOpts{
32+
KubeClientQPS: float32(*kubeClientQPS),
33+
KubeClientBurst: *kubeClientBurst,
34+
},
2335
LogCtx: utils.SetupLog(),
2436
}
37+
2538
pluginMap := map[string]goPlugin.Plugin{
2639
"RpcTrafficRouterPlugin": &rolloutsPlugin.RpcTrafficRouterPlugin{Impl: rpcPluginImp},
2740
}
41+
2842
goPlugin.Serve(&goPlugin.ServeConfig{
2943
HandshakeConfig: handshakeConfig,
3044
Plugins: pluginMap,

pkg/plugin/plugin.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import (
44
"encoding/json"
55
"fmt"
66

7-
"github.com/argoproj-labs/rollouts-plugin-trafficrouter-gatewayapi/internal/defaults"
8-
"github.com/argoproj-labs/rollouts-plugin-trafficrouter-gatewayapi/internal/utils"
97
"github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1"
108
pluginTypes "github.com/argoproj/argo-rollouts/utils/plugin/types"
119
"github.com/go-playground/validator/v10"
1210
"k8s.io/client-go/kubernetes"
1311
gatewayApiClientset "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned"
12+
13+
"github.com/argoproj-labs/rollouts-plugin-trafficrouter-gatewayapi/internal/defaults"
14+
"github.com/argoproj-labs/rollouts-plugin-trafficrouter-gatewayapi/internal/utils"
1415
)
1516

1617
const (
@@ -19,6 +20,8 @@ const (
1920
)
2021

2122
func (r *RpcPlugin) InitPlugin() pluginTypes.RpcError {
23+
log := utils.SetupLog()
24+
2225
if r.IsTest {
2326
return pluginTypes.RpcError{}
2427
}
@@ -28,6 +31,17 @@ func (r *RpcPlugin) InitPlugin() pluginTypes.RpcError {
2831
ErrorString: err.Error(),
2932
}
3033
}
34+
35+
// Configure command-line overrides for the Kubernetes client:
36+
if r.CommandLineOpts.KubeClientQPS != 0 {
37+
log.Infof("KubeClientQPS set to: %f", r.CommandLineOpts.KubeClientQPS)
38+
kubeConfig.QPS = r.CommandLineOpts.KubeClientQPS
39+
}
40+
if r.CommandLineOpts.KubeClientBurst != 0 {
41+
log.Infof("KubeClientBurst set to: %d", r.CommandLineOpts.KubeClientBurst)
42+
kubeConfig.Burst = r.CommandLineOpts.KubeClientBurst
43+
}
44+
3145
gatewayAPIClientset, err := gatewayApiClientset.NewForConfig(kubeConfig)
3246
if err != nil {
3347
return pluginTypes.RpcError{

pkg/plugin/types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ import (
1313
gatewayApiClientv1alpha2 "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/typed/apis/v1alpha2"
1414
)
1515

16+
type CommandLineOpts struct {
17+
KubeClientQPS float32
18+
KubeClientBurst int
19+
}
20+
1621
type RpcPlugin struct {
22+
CommandLineOpts CommandLineOpts
1723
HTTPRouteClient gatewayApiClientv1.HTTPRouteInterface
1824
TCPRouteClient gatewayApiClientv1alpha2.TCPRouteInterface
1925
GRPCRouteClient gatewayApiClientv1.GRPCRouteInterface

0 commit comments

Comments
 (0)