1

I see a cache directory in the .kube/ directory of my kubectl. I tried to find the purpose of this cache and how kubectl uses it in the kubernetes documentation here but couldn't find any clue.

What does kubectl store in the .kube/cache directory? and how this cache is used in the kubectl operation? What exactly kubectl caches?

Akshay Hiremath
  • 141
  • 1
  • 5

1 Answers1

2

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

mdaniel
  • 2,338
  • 1
  • 8
  • 13