Skip to content

Commit

Permalink
Implement burst_limit parameter #1011
Browse files Browse the repository at this point in the history
Adds the ability to configure the burst_limit of the client-go client
used by Helm. If your cluster has a lot of CRDs e.g. when Crossplane is installed, the DiscoveryClient performs many API calls potentially triggering client-side rate limiting.
Increasing the burst_limit reduces this throttling, significantly speeding up install or update actions, sometimes by a factor 10.

Co-authored-by: Marco Franssen <marco.franssen@philips.com>
  • Loading branch information
loafoe and marcofranssen committed Dec 12, 2022
1 parent 425234c commit f8f5486
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions helm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ func Provider() *schema.Provider {
}
},
},
"burst_limit": {
Type: schema.TypeInt,
Optional: true,
Default: 100,
Description: "Helm burst limit. Increase this if you have a cluster with many CRDs",
},
"kubernetes": {
Type: schema.TypeList,
MaxItems: 1,
Expand Down
7 changes: 5 additions & 2 deletions helm/structure_kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
type KubeConfig struct {
ClientConfig clientcmd.ClientConfig

Burst int

sync.Mutex
}

Expand All @@ -44,7 +46,7 @@ func (k *KubeConfig) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, er
// The more groups you have, the more discovery requests you need to make.
// given 25 groups (our groups + a few custom resources) with one-ish version each, discovery needs to make 50 requests
// double it just so we don't end up here again for a while. This config is only used for discovery.
config.Burst = 100
config.Burst = k.Burst

return memcached.NewMemCacheClient(discovery.NewDiscoveryClientForConfigOrDie(config)), nil
}
Expand Down Expand Up @@ -186,6 +188,7 @@ func newKubeConfig(configData *schema.ResourceData, namespace *string) (*KubeCon
if namespace != nil {
overrides.Context.Namespace = *namespace
}
burstLimit := configData.Get("burst_limit").(int)

client := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loader, overrides)
if client == nil {
Expand All @@ -194,5 +197,5 @@ func newKubeConfig(configData *schema.ResourceData, namespace *string) (*KubeCon
}
log.Printf("[INFO] Successfully initialized kubernetes config")

return &KubeConfig{ClientConfig: client}, nil
return &KubeConfig{ClientConfig: client, Burst: burstLimit}, nil
}
1 change: 1 addition & 0 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ The following arguments are supported:
* `repository_cache` - (Optional) The path to the file containing cached repository indexes. Defaults to `HELM_REPOSITORY_CACHE` env if it is set, otherwise uses the default path set by helm.
* `helm_driver` - (Optional) "The backend storage driver. Valid values are: `configmap`, `secret`, `memory`, `sql`. Defaults to `secret`.
Note: Regarding the sql driver, as of helm v3.2.0 SQL support exists only for the postgres dialect. The connection string can be configured by setting the `HELM_DRIVER_SQL_CONNECTION_STRING` environment variable e.g. `HELM_DRIVER_SQL_CONNECTION_STRING=postgres://username:password@host/dbname` more info [here](https://pkg.go.dev/github.com/lib/pq).
* `burst_limit` - (Optional) The helm burst limit to use. Set this value higher if your cluster has many CRDs. Default: `100`
* `kubernetes` - Kubernetes configuration block.

The `kubernetes` block supports:
Expand Down

0 comments on commit f8f5486

Please sign in to comment.