What does kubectl store in the cache?

Solution 1:

By cursory examination, one will observe the discovery directory is the kubectl api-resources output, per cluster hostname, and the http sibling directory contains the response bodies for each of those individual api-resource requests. The latter is used for parsing its Etag in order to know whether the cache is intact or not.

The api-resources are a formal description of the verbs, URIs, and request/response bodies tolerated by a given kubernetes cluster, which includes any installed Custom Resource Definitions

The gory details are described by the godoc for NewCachedDiscoveryClientForConfig and that ~/.kube/config directory itself is under user influence via the --cache-dir flag to kubectl, as shown in the genericclioptions config_flags.go