Skip to content

Commit

Permalink
add qps/burst flag for k8s client
Browse files Browse the repository at this point in the history
  • Loading branch information
whitebear009 committed Nov 29, 2022
1 parent 41ec178 commit 572a3d6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/cmd/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ type AdapterBase struct {
// DiscoveryInterval specifies the interval at which to recheck discovery
// information for the discovery RESTMapper. It's set from a flag.
DiscoveryInterval time.Duration
// ClientQPS specifies the maximum QPS for the client. It's set from a flag.
ClientQPS float32
// ClientBurst specifies the maximum burst for client-side throttle. It's set from a flag.
ClientBurst int

// FlagSet is the flagset to add flags to.
// It defaults to the normal CommandLine flags
Expand Down Expand Up @@ -111,6 +115,8 @@ func (b *AdapterBase) InstallFlags() {
"any described objects")
b.FlagSet.DurationVar(&b.DiscoveryInterval, "discovery-interval", b.DiscoveryInterval,
"interval at which to refresh API discovery information")
b.FlagSet.Float32Var(&b.ClientQPS, "client-qps", b.ClientQPS, "maximum QPS for client")
b.FlagSet.IntVar(&b.ClientBurst, "client-burst", b.ClientBurst, "maximum burst for client-side throttle")
})
}

Expand Down Expand Up @@ -153,6 +159,13 @@ func (b *AdapterBase) ClientConfig() (*rest.Config, error) {
}
b.clientConfig = clientConfig
}

if b.ClientQPS > 0 {
b.clientConfig.QPS = b.ClientQPS
}
if b.ClientBurst > 0 {
b.clientConfig.Burst = b.ClientBurst
}
return b.clientConfig, nil
}

Expand Down

0 comments on commit 572a3d6

Please sign in to comment.