Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit da20c31

Browse files
authored
Merge pull request #10 from cwdsuzhou/March/expose_qps
Feature: expose kube api qps and burst
2 parents ad1d791 + 49515c8 commit da20c31

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

internal/commands/root/flag.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ func installFlags(flags *pflag.FlagSet, c *opts.Opts) {
4343
flags.DurationVar(&c.InformerResyncPeriod, "full-resync-period", c.InformerResyncPeriod, "how often to perform a full resync of pods between kubernetes and the provider")
4444
flags.DurationVar(&c.StartupTimeout, "startup-timeout", c.StartupTimeout, "How long to wait for the virtual-kubelet to start")
4545

46+
flags.Int32Var(&c.KubeAPIQPS, "kube-api-qps", c.KubeAPIQPS,
47+
"kubeAPIQPS is the QPS to use while talking with kubernetes apiserver")
48+
flags.Int32Var(&c.KubeAPIBurst, "kube-api-burst", c.KubeAPIBurst,
49+
"kubeAPIBurst is the burst to allow while talking with kubernetes apiserver")
50+
4651
flagset := flag.NewFlagSet("klog", flag.PanicOnError)
4752
klog.InitFlags(flagset)
4853
flagset.VisitAll(func(f *flag.Flag) {

internal/commands/root/root.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func runRootCommand(ctx context.Context, s *provider.Store, c *opts.Opts) error
6666
return errors.Errorf("provider %q not found", c.Provider)
6767
}
6868

69-
client, err := newClient(c.KubeConfigPath)
69+
client, err := newClient(c.KubeConfigPath, c.KubeAPIQPS, c.KubeAPIBurst)
7070
if err != nil {
7171
return err
7272
}
@@ -246,7 +246,7 @@ func waitFor(ctx context.Context, time time.Duration, ready <-chan struct{}) err
246246
}
247247
}
248248

249-
func newClient(configPath string) (*kubernetes.Clientset, error) {
249+
func newClient(configPath string, qps, burst int32) (*kubernetes.Clientset, error) {
250250
var config *rest.Config
251251

252252
// Check if the kubeConfig file exists.
@@ -264,6 +264,14 @@ func newClient(configPath string) (*kubernetes.Clientset, error) {
264264
}
265265
}
266266

267+
if qps != 0 {
268+
config.QPS = float32(qps)
269+
}
270+
271+
if burst != 0 {
272+
config.Burst = int(burst)
273+
}
274+
267275
if masterURI := os.Getenv("MASTER_URI"); masterURI != "" {
268276
config.Host = masterURI
269277
}

opts/opts.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ type Opts struct {
8282
// Startup Timeout is how long to wait for the kubelet to start
8383
StartupTimeout time.Duration
8484

85+
// KubeAPIQPS is the QPS to use while talking with kubernetes apiserver
86+
KubeAPIQPS int32
87+
// KubeAPIBurst is the burst to allow while talking with kubernetes apiserver
88+
KubeAPIBurst int32
89+
8590
Version string
8691
}
8792

0 commit comments

Comments
 (0)