Where Is the kubectl Config File?
kubectl reads clusters and credentials from ~/.kube/config on every desktop OS by default.
Last updated
kubectl centers on ~/.kube/config holding clusters, users, contexts, and credentials or their file references. The KUBECONFIG variable can point elsewhere or merge several files with colon separators. Cloud CLIs write this file on login.
Guard it like a password store since embedded tokens grant cluster access. Split team and personal contexts across files and merge at runtime. Back up the folder before cloud CLI logins that rewrite entries.
Where kubectl stores this, by platform
C:\Users\[You]\.kube\config
Same role as other platforms. Cloud CLIs and WSL mounts edit it too. Keep permissions tight even though Windows lacks chmod habits.
~/.kube/config
Default path, chmod 600 recommended. Docker Desktop and cloud CLIs append contexts here. Cache beside it rebuilds safely.
~/.kube/config
KUBECONFIG override can relocate or merge files. Kind, minikube, and k3s all write here by default. Version the non secret parts only.
Frequently asked questions
How do I use multiple kubeconfigs?
Set KUBECONFIG to a colon separated list and kubectl merges them. Keep files per cluster or team. Current context switches with config use-context.
Where are kubectl credentials stored?
Inline in kubeconfig or in referenced files like client certificates. Cloud providers add exec plugins that fetch tokens. Never commit the folder to git.
Notice an outdated path? Let us know.