Change:
The discovery cache for kubectl is defaulted to 10 minutes: That means that every 10 minutes of using against a cluster, it runs API requests against all group versions, which can take quite some time on clusters with many operators installed (like , , , etc.). I previously wrote that shows that every 10 minutes a simple 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: 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. Running the discovery cache every 10 minutes has a significant productivity impact on using 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.
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the label and provide further guidance. The label can be by org members by writing in a comment. <detailsInstructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
/sig cli
I would like to work on this issue.
/assign

Discussion:
k8s.io/apimachinery v0.0.0 k8s.io/client-go v0.0.0 k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 <ins> k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 </ins> sigs.k8s.io/kustomize/api v0.10.1 sigs.k8s.io/kustomize/kyaml v0.13.0 sigs.k8s.io/yaml v1.2.0

"k8s.io/client-go/restmapper" "k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/util/homedir" <ins> utilpointer "k8s.io/utils/pointer" </ins> ) const (

httpCacheDir := filepath.Join(cacheDir, "http") discoveryCacheDir := computeDiscoverCacheDir(filepath.Join(cacheDir, "discovery"), config.Host) <del> return diskcached.NewCachedDiscoveryClientForConfig(config, discoveryCacheDir, httpCacheDir, time.Duration(10*time.Minute)) </del> <ins> return diskcached.NewCachedDiscoveryClientForConfig(config, discoveryCacheDir, httpCacheDir, time.Duration(6*time.Hour)) </ins> } // ToRESTMapper returns a mapper.

// WithDeprecatedPasswordFlag enables the username and password config flags func (f *ConfigFlags) WithDeprecatedPasswordFlag() *ConfigFlags { <del> f.Username = stringptr("") f.Password = stringptr("") </del> <ins> f.Username = utilpointer.String("") f.Password = utilpointer.String("") </ins> return f }

return &ConfigFlags{ Insecure:   &insecure, <del> Timeout:    stringptr("0"), KubeConfig: stringptr(""), CacheDir:         stringptr(defaultCacheDir), ClusterName:      stringptr(""), AuthInfoName:     stringptr(""), Context:          stringptr(""), Namespace:        stringptr(""), APIServer:        stringptr(""), TLSServerName:    stringptr(""), CertFile:         stringptr(""), KeyFile:          stringptr(""), CAFile:           stringptr(""), BearerToken:      stringptr(""), Impersonate:      stringptr(""), ImpersonateUID:   stringptr(""), </del> <ins> Timeout:    utilpointer.String("0"), KubeConfig: utilpointer.String(""), CacheDir:         utilpointer.String(defaultCacheDir), ClusterName:      utilpointer.String(""), AuthInfoName:     utilpointer.String(""), Context:          utilpointer.String(""), Namespace:        utilpointer.String(""), APIServer:        utilpointer.String(""), TLSServerName:    utilpointer.String(""), CertFile:         utilpointer.String(""), KeyFile:          utilpointer.String(""), CAFile:           utilpointer.String(""), BearerToken:      utilpointer.String(""), Impersonate:      utilpointer.String(""), ImpersonateUID:   utilpointer.String(""), </ins> ImpersonateGroup: &impersonateGroup, usePersistentConfig: usePersistentConfig,

} } <del> func stringptr(val string) *string { return &val } </del> // overlyCautiousIllegalFileCharacters matches characters that *might* not be supported.  Windows is really restrictive, so this is really restrictive var overlyCautiousIllegalFileCharacters = regexp.MustCompile(`[^(w/.)]`)