WindowsmacOSLinux

Where Is the Kubernetes kubeconfig File?

Default kubeconfig path on Windows, macOS and Linux, how KUBECONFIG merging works, and where managed tools hide extras.

Last updated

kubectl reads cluster credentials from a file called config inside a .kube folder in your home directory. That single file lists clusters, users and contexts. The kubectl config get-contexts command shows what is inside without opening it.

The KUBECONFIG variable can point elsewhere or merge several files with a separator. Managed tools like Docker Desktop, minikube, kind and cloud CLIs write into the same default file. Back it up before installing a new distribution, since installers overwrite entries.

Where Kubernetes stores this, by platform

Windows
C:\Users\[Username]\.kube\config

kubectl merges files listed in %KUBECONFIG% with a semicolon separator. WSL users have a separate ~/.kube/config inside Linux that does not see the Windows file.

macOS
~/.kube/config

Docker Desktop and Rancher Desktop append contexts here. Use kubectl config use-context to switch. Keep the file at 600 permissions since it holds tokens.

Linux
~/.kube/config

Colon separates multiple files in $KUBECONFIG on Linux and Mac. Kind and minikube add entries automatically. Cache files sit in ~/.kube/cache beside the config.

Frequently asked questions

How do I use two clusters at once?

Set KUBECONFIG to both files: two paths joined by a colon on Mac and Linux, semicolon on Windows. kubectl then sees contexts from each. Switch with kubectl config use-context when needed.

kubectl says no configuration has been provided, what now?

The default config file is missing or empty. Recreate ~/.kube/config from your provider (aws eks update-kubeconfig, az aks get-credentials, gcloud container clusters get-credentials) and retry.

Notice an outdated path? Let us know.