Skip to content

Commit

Permalink
Add ratelimitting parameters to keda metrics apiserver to allow overr…
Browse files Browse the repository at this point in the history
…ide of client defaults (#1944)

Signed-off-by: Chris Berry <bez625@gmail.com>
  • Loading branch information
Bez625 authored Jul 12, 2021
1 parent 6eb846d commit 48f2605
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- Don't panic when HashiCorp Vault path doesn't exist ([#1864](https://github.com/kedacore/keda/pull/1864))
- Allow influxdb `authToken`, `serverURL`, and `organizationName` to be sourced from `(Cluster)TriggerAuthentication` ([#1904](https://github.com/kedacore/keda/pull/1904))
- IBM MQ scaler password handling fix ([#1939](https://github.com/kedacore/keda/pull/1939))
- Metrics APIServer: Add ratelimiting parameters to override client ([#1944](https://github.com/kedacore/keda/pull/1944))

### Breaking Changes

Expand Down
13 changes: 11 additions & 2 deletions adapter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,20 @@ type Adapter struct {
var logger = klogr.New().WithName("keda_metrics_adapter")

var (
prometheusMetricsPort int
prometheusMetricsPath string
prometheusMetricsPort int
prometheusMetricsPath string
adapterClientRequestQPS float32
adapterClientRequestBurst int
)

func (a *Adapter) makeProvider(globalHTTPTimeout time.Duration) (provider.MetricsProvider, error) {
// Get a config to talk to the apiserver
cfg, err := config.GetConfig()
if cfg != nil {
cfg.QPS = adapterClientRequestQPS
cfg.Burst = adapterClientRequestBurst
}

if err != nil {
logger.Error(err, "failed to get the config")
return nil, fmt.Errorf("failed to get the config (%s)", err)
Expand Down Expand Up @@ -129,6 +136,8 @@ func main() {
cmd.Flags().AddGoFlagSet(flag.CommandLine) // make sure we get the klog flags
cmd.Flags().IntVar(&prometheusMetricsPort, "metrics-port", 9022, "Set the port to expose prometheus metrics")
cmd.Flags().StringVar(&prometheusMetricsPath, "metrics-path", "/metrics", "Set the path for the prometheus metrics endpoint")
cmd.Flags().Float32Var(&adapterClientRequestQPS, "kube-api-qps", 20.0, "Set the QPS rate for throttling requests sent to the apiserver")
cmd.Flags().IntVar(&adapterClientRequestBurst, "kube-api-burst", 30, "Set the burst for throttling requests sent to the apiserver")
if err := cmd.Flags().Parse(os.Args); err != nil {
return
}
Expand Down

0 comments on commit 48f2605

Please sign in to comment.