mirror of
https://github.com/helm/helm.git
synced 2026-05-28 04:35:48 -04:00
Add qps/HELM_QPS parameter
Signed-off-by: Andy Smith <iamasmith.home@gmail.com>
This commit is contained in:
parent
387ba9c5b7
commit
415af5b0e9
4 changed files with 57 additions and 29 deletions
|
|
@ -45,31 +45,32 @@ Common actions for Helm:
|
|||
|
||||
Environment variables:
|
||||
|
||||
| Name | Description |
|
||||
|------------------------------------|---------------------------------------------------------------------------------------------------|
|
||||
| $HELM_CACHE_HOME | set an alternative location for storing cached files. |
|
||||
| $HELM_CONFIG_HOME | set an alternative location for storing Helm configuration. |
|
||||
| $HELM_DATA_HOME | set an alternative location for storing Helm data. |
|
||||
| $HELM_DEBUG | indicate whether or not Helm is running in Debug mode |
|
||||
| $HELM_DRIVER | set the backend storage driver. Values are: configmap, secret, memory, sql. |
|
||||
| $HELM_DRIVER_SQL_CONNECTION_STRING | set the connection string the SQL storage driver should use. |
|
||||
| $HELM_MAX_HISTORY | set the maximum number of helm release history. |
|
||||
| $HELM_NAMESPACE | set the namespace used for the helm operations. |
|
||||
| $HELM_NO_PLUGINS | disable plugins. Set HELM_NO_PLUGINS=1 to disable plugins. |
|
||||
| $HELM_PLUGINS | set the path to the plugins directory |
|
||||
| $HELM_REGISTRY_CONFIG | set the path to the registry config file. |
|
||||
| $HELM_REPOSITORY_CACHE | set the path to the repository cache directory |
|
||||
| $HELM_REPOSITORY_CONFIG | set the path to the repositories file. |
|
||||
| $KUBECONFIG | set an alternative Kubernetes configuration file (default "~/.kube/config") |
|
||||
| $HELM_KUBEAPISERVER | set the Kubernetes API Server Endpoint for authentication |
|
||||
| $HELM_KUBECAFILE | set the Kubernetes certificate authority file. |
|
||||
| $HELM_KUBEASGROUPS | set the Groups to use for impersonation using a comma-separated list. |
|
||||
| $HELM_KUBEASUSER | set the Username to impersonate for the operation. |
|
||||
| $HELM_KUBECONTEXT | set the name of the kubeconfig context. |
|
||||
| $HELM_KUBETOKEN | set the Bearer KubeToken used for authentication. |
|
||||
| $HELM_KUBEINSECURE_SKIP_TLS_VERIFY | indicate if the Kubernetes API server's certificate validation should be skipped (insecure) |
|
||||
| $HELM_KUBETLS_SERVER_NAME | set the server name used to validate the Kubernetes API server certificate |
|
||||
| $HELM_BURST_LIMIT | set the default burst limit in the case the server contains many CRDs (default 100, -1 to disable)|
|
||||
| Name | Description |
|
||||
|------------------------------------|------------------------------------------------------------------------------------------------------------|
|
||||
| $HELM_CACHE_HOME | set an alternative location for storing cached files. |
|
||||
| $HELM_CONFIG_HOME | set an alternative location for storing Helm configuration. |
|
||||
| $HELM_DATA_HOME | set an alternative location for storing Helm data. |
|
||||
| $HELM_DEBUG | indicate whether or not Helm is running in Debug mode |
|
||||
| $HELM_DRIVER | set the backend storage driver. Values are: configmap, secret, memory, sql. |
|
||||
| $HELM_DRIVER_SQL_CONNECTION_STRING | set the connection string the SQL storage driver should use. |
|
||||
| $HELM_MAX_HISTORY | set the maximum number of helm release history. |
|
||||
| $HELM_NAMESPACE | set the namespace used for the helm operations. |
|
||||
| $HELM_NO_PLUGINS | disable plugins. Set HELM_NO_PLUGINS=1 to disable plugins. |
|
||||
| $HELM_PLUGINS | set the path to the plugins directory |
|
||||
| $HELM_REGISTRY_CONFIG | set the path to the registry config file. |
|
||||
| $HELM_REPOSITORY_CACHE | set the path to the repository cache directory |
|
||||
| $HELM_REPOSITORY_CONFIG | set the path to the repositories file. |
|
||||
| $KUBECONFIG | set an alternative Kubernetes configuration file (default "~/.kube/config") |
|
||||
| $HELM_KUBEAPISERVER | set the Kubernetes API Server Endpoint for authentication |
|
||||
| $HELM_KUBECAFILE | set the Kubernetes certificate authority file. |
|
||||
| $HELM_KUBEASGROUPS | set the Groups to use for impersonation using a comma-separated list. |
|
||||
| $HELM_KUBEASUSER | set the Username to impersonate for the operation. |
|
||||
| $HELM_KUBECONTEXT | set the name of the kubeconfig context. |
|
||||
| $HELM_KUBETOKEN | set the Bearer KubeToken used for authentication. |
|
||||
| $HELM_KUBEINSECURE_SKIP_TLS_VERIFY | indicate if the Kubernetes API server's certificate validation should be skipped (insecure) |
|
||||
| $HELM_KUBETLS_SERVER_NAME | set the server name used to validate the Kubernetes API server certificate |
|
||||
| $HELM_BURST_LIMIT | set the default burst limit in the case the server contains many CRDs (default 100, -1 to disable) |
|
||||
| $HELM_QPS | set the Queries Per Second in cases where a high number of calls exceed the option for higher burst values |
|
||||
|
||||
Helm stores cache, configuration, and data based on the following configuration order:
|
||||
|
||||
|
|
|
|||
1
cmd/helm/testdata/output/env-comp.txt
vendored
1
cmd/helm/testdata/output/env-comp.txt
vendored
|
|
@ -15,6 +15,7 @@ HELM_KUBETOKEN
|
|||
HELM_MAX_HISTORY
|
||||
HELM_NAMESPACE
|
||||
HELM_PLUGINS
|
||||
HELM_QPS
|
||||
HELM_REGISTRY_CONFIG
|
||||
HELM_REPOSITORY_CACHE
|
||||
HELM_REPOSITORY_CONFIG
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ const defaultMaxHistory = 10
|
|||
// defaultBurstLimit sets the default client-side throttling limit
|
||||
const defaultBurstLimit = 100
|
||||
|
||||
// defaultQPS sets the default QPS value to 0 to to use library defaults unless specified
|
||||
const defaultQPS = float32(0)
|
||||
|
||||
// EnvSettings describes all of the environment settings.
|
||||
type EnvSettings struct {
|
||||
namespace string
|
||||
|
|
@ -83,6 +86,8 @@ type EnvSettings struct {
|
|||
MaxHistory int
|
||||
// BurstLimit is the default client-side throttling limit.
|
||||
BurstLimit int
|
||||
// QPS is queries per second which may be used to avoid throttling.
|
||||
QPS float32
|
||||
}
|
||||
|
||||
func New() *EnvSettings {
|
||||
|
|
@ -102,6 +107,7 @@ func New() *EnvSettings {
|
|||
RepositoryConfig: envOr("HELM_REPOSITORY_CONFIG", helmpath.ConfigPath("repositories.yaml")),
|
||||
RepositoryCache: envOr("HELM_REPOSITORY_CACHE", helmpath.CachePath("repository")),
|
||||
BurstLimit: envIntOr("HELM_BURST_LIMIT", defaultBurstLimit),
|
||||
QPS: envFloat32Or("HELM_QPS", defaultQPS),
|
||||
}
|
||||
env.Debug, _ = strconv.ParseBool(os.Getenv("HELM_DEBUG"))
|
||||
|
||||
|
|
@ -119,6 +125,7 @@ func New() *EnvSettings {
|
|||
ImpersonateGroup: &env.KubeAsGroups,
|
||||
WrapConfigFn: func(config *rest.Config) *rest.Config {
|
||||
config.Burst = env.BurstLimit
|
||||
config.QPS = env.QPS
|
||||
config.Wrap(func(rt http.RoundTripper) http.RoundTripper {
|
||||
return &retryingRoundTripper{wrapped: rt}
|
||||
})
|
||||
|
|
@ -146,6 +153,7 @@ func (s *EnvSettings) AddFlags(fs *pflag.FlagSet) {
|
|||
fs.StringVar(&s.RepositoryConfig, "repository-config", s.RepositoryConfig, "path to the file containing repository names and URLs")
|
||||
fs.StringVar(&s.RepositoryCache, "repository-cache", s.RepositoryCache, "path to the file containing cached repository indexes")
|
||||
fs.IntVar(&s.BurstLimit, "burst-limit", s.BurstLimit, "client-side default throttling limit")
|
||||
fs.Float32Var(&s.QPS, "qps", s.QPS, "queries per second used when communicating with the Kubernetes API, not including bursting")
|
||||
}
|
||||
|
||||
func envOr(name, def string) string {
|
||||
|
|
@ -179,6 +187,18 @@ func envIntOr(name string, def int) int {
|
|||
return ret
|
||||
}
|
||||
|
||||
func envFloat32Or(name string, def float32) float32 {
|
||||
if name == "" {
|
||||
return def
|
||||
}
|
||||
envVal := envOr(name, strconv.FormatFloat(float64(def), 'f', 2, 32))
|
||||
ret, err := strconv.ParseFloat(envVal, 32)
|
||||
if err != nil {
|
||||
return def
|
||||
}
|
||||
return float32(ret)
|
||||
}
|
||||
|
||||
func envCSV(name string) (ls []string) {
|
||||
trimmed := strings.Trim(os.Getenv(name), ", ")
|
||||
if trimmed != "" {
|
||||
|
|
@ -201,6 +221,7 @@ func (s *EnvSettings) EnvVars() map[string]string {
|
|||
"HELM_NAMESPACE": s.Namespace(),
|
||||
"HELM_MAX_HISTORY": strconv.Itoa(s.MaxHistory),
|
||||
"HELM_BURST_LIMIT": strconv.Itoa(s.BurstLimit),
|
||||
"HELM_QPS": strconv.FormatFloat(float64(s.QPS), 'f', 2, 32),
|
||||
|
||||
// broken, these are populated from helm flags and not kubeconfig.
|
||||
"HELM_KUBECONTEXT": s.KubeContext,
|
||||
|
|
|
|||
|
|
@ -59,20 +59,23 @@ func TestEnvSettings(t *testing.T) {
|
|||
kubeInsecure bool
|
||||
kubeTLSServer string
|
||||
burstLimit int
|
||||
qps float32
|
||||
}{
|
||||
{
|
||||
name: "defaults",
|
||||
ns: "default",
|
||||
maxhistory: defaultMaxHistory,
|
||||
burstLimit: defaultBurstLimit,
|
||||
qps: defaultQPS,
|
||||
},
|
||||
{
|
||||
name: "with flags set",
|
||||
args: "--debug --namespace=myns --kube-as-user=poro --kube-as-group=admins --kube-as-group=teatime --kube-as-group=snackeaters --kube-ca-file=/tmp/ca.crt --burst-limit 100 --kube-insecure-skip-tls-verify=true --kube-tls-server-name=example.org",
|
||||
args: "--debug --namespace=myns --kube-as-user=poro --kube-as-group=admins --kube-as-group=teatime --kube-as-group=snackeaters --kube-ca-file=/tmp/ca.crt --burst-limit 100 --qps 50.12 --kube-insecure-skip-tls-verify=true --kube-tls-server-name=example.org",
|
||||
ns: "myns",
|
||||
debug: true,
|
||||
maxhistory: defaultMaxHistory,
|
||||
burstLimit: 100,
|
||||
qps: 50.12,
|
||||
kubeAsUser: "poro",
|
||||
kubeAsGroups: []string{"admins", "teatime", "snackeaters"},
|
||||
kubeCaFile: "/tmp/ca.crt",
|
||||
|
|
@ -81,10 +84,11 @@ func TestEnvSettings(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "with envvars set",
|
||||
envvars: map[string]string{"HELM_DEBUG": "1", "HELM_NAMESPACE": "yourns", "HELM_KUBEASUSER": "pikachu", "HELM_KUBEASGROUPS": ",,,operators,snackeaters,partyanimals", "HELM_MAX_HISTORY": "5", "HELM_KUBECAFILE": "/tmp/ca.crt", "HELM_BURST_LIMIT": "150", "HELM_KUBEINSECURE_SKIP_TLS_VERIFY": "true", "HELM_KUBETLS_SERVER_NAME": "example.org"},
|
||||
envvars: map[string]string{"HELM_DEBUG": "1", "HELM_NAMESPACE": "yourns", "HELM_KUBEASUSER": "pikachu", "HELM_KUBEASGROUPS": ",,,operators,snackeaters,partyanimals", "HELM_MAX_HISTORY": "5", "HELM_KUBECAFILE": "/tmp/ca.crt", "HELM_BURST_LIMIT": "150", "HELM_KUBEINSECURE_SKIP_TLS_VERIFY": "true", "HELM_KUBETLS_SERVER_NAME": "example.org", "HELM_QPS": "60.34"},
|
||||
ns: "yourns",
|
||||
maxhistory: 5,
|
||||
burstLimit: 150,
|
||||
qps: 60.34,
|
||||
debug: true,
|
||||
kubeAsUser: "pikachu",
|
||||
kubeAsGroups: []string{"operators", "snackeaters", "partyanimals"},
|
||||
|
|
@ -94,12 +98,13 @@ func TestEnvSettings(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "with flags and envvars set",
|
||||
args: "--debug --namespace=myns --kube-as-user=poro --kube-as-group=admins --kube-as-group=teatime --kube-as-group=snackeaters --kube-ca-file=/my/ca.crt --burst-limit 175 --kube-insecure-skip-tls-verify=true --kube-tls-server-name=example.org",
|
||||
envvars: map[string]string{"HELM_DEBUG": "1", "HELM_NAMESPACE": "yourns", "HELM_KUBEASUSER": "pikachu", "HELM_KUBEASGROUPS": ",,,operators,snackeaters,partyanimals", "HELM_MAX_HISTORY": "5", "HELM_KUBECAFILE": "/tmp/ca.crt", "HELM_BURST_LIMIT": "200", "HELM_KUBEINSECURE_SKIP_TLS_VERIFY": "true", "HELM_KUBETLS_SERVER_NAME": "example.org"},
|
||||
args: "--debug --namespace=myns --kube-as-user=poro --kube-as-group=admins --kube-as-group=teatime --kube-as-group=snackeaters --kube-ca-file=/my/ca.crt --burst-limit 175 --qps 70 --kube-insecure-skip-tls-verify=true --kube-tls-server-name=example.org",
|
||||
envvars: map[string]string{"HELM_DEBUG": "1", "HELM_NAMESPACE": "yourns", "HELM_KUBEASUSER": "pikachu", "HELM_KUBEASGROUPS": ",,,operators,snackeaters,partyanimals", "HELM_MAX_HISTORY": "5", "HELM_KUBECAFILE": "/tmp/ca.crt", "HELM_BURST_LIMIT": "200", "HELM_KUBEINSECURE_SKIP_TLS_VERIFY": "true", "HELM_KUBETLS_SERVER_NAME": "example.org", "HELM_QPS": "40"},
|
||||
ns: "myns",
|
||||
debug: true,
|
||||
maxhistory: 5,
|
||||
burstLimit: 175,
|
||||
qps: 70,
|
||||
kubeAsUser: "poro",
|
||||
kubeAsGroups: []string{"admins", "teatime", "snackeaters"},
|
||||
kubeCaFile: "/my/ca.crt",
|
||||
|
|
|
|||
Loading…
Reference in a new issue