What would you like to be added?
The discovery cache for kubectl is defaulted to 10 minutes:
|
return diskcached.NewCachedDiscoveryClientForConfig(config, discoveryCacheDir, httpCacheDir, time.Duration(10*time.Minute)) |
That means that every 10 minutes of using kubectl against a cluster, it runs API requests against all group versions, which can take quite some time on clusters with many operators installed (like crossplane.io, GCP Config Connector, Azure Service Operator, etc.). I previously wrote this report that shows that every 10 minutes a simple kubectl get pods makes 170 API requests against a test cluster, vs 4 API requests when the cache exists. That results in significant productivity implications against such clusters. Here is a time comparison between a request that runs the discovery cache vs one that doesn't:
$ time kubectl get pods -n default
kubectl get pods -n default 0.50s user 1.19s system 11% cpu 14.174 total
$ time kubectl get --raw "/api/v1/namespaces/default/pods"
kubectl get --raw "/api/v1/namespaces/default/pods" 0.06s user 0.03s system 23% cpu 0.398 total
The discovery cache doesn't really have to run every 10 minutes, as CRDs don't change that often. A lot of unnecessary load is created on clients and servers.
This issue is raised to change the discovery cache default to 24 hours and also to make the discovery cache ttl configurable.
Why is this needed?
Running the discovery cache every 10 minutes has a significant productivity impact on using kubectl on clusters with many CRDs as it is taking time to run these unnecessary requests.
The discovery cache doesn't really have to run every 10 minutes, as CRDs don't change that often. A lot of unnecessary load is created on clients and servers.
What would you like to be added?
The discovery cache for kubectl is defaulted to 10 minutes:
kubernetes/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/config_flags.go
Line 253 in 0fb7184
That means that every 10 minutes of using
kubectlagainst a cluster, it runs API requests against all group versions, which can take quite some time on clusters with many operators installed (like crossplane.io, GCP Config Connector, Azure Service Operator, etc.). I previously wrote this report that shows that every 10 minutes a simplekubectl get podsmakes 170 API requests against a test cluster, vs 4 API requests when the cache exists. That results in significant productivity implications against such clusters. Here is a time comparison between a request that runs the discovery cache vs one that doesn't:The discovery cache doesn't really have to run every 10 minutes, as CRDs don't change that often. A lot of unnecessary load is created on clients and servers.
This issue is raised to change the discovery cache default to 24 hours and also to make the discovery cache ttl configurable.
Why is this needed?
Running the discovery cache every 10 minutes has a significant productivity impact on using
kubectlon clusters with many CRDs as it is taking time to run these unnecessary requests.The discovery cache doesn't really have to run every 10 minutes, as CRDs don't change that often. A lot of unnecessary load is created on clients and servers.