WindowsmacOSLinux

Where Does Kubectx Store Contexts?

Kubectx and kubens state on desktop OSes, which is just your kubeconfig plus tiny context files.

Last updated

Kubectx and kubens are thin wrappers over kubeconfig. There is no separate database. Current context and namespace resolve from ~/.kube/config on every platform, with KUBECONFIG able to redirect it.

Some installs add cached previous namespace files beside the binary, but those are conveniences. Lose them and nothing breaks. Lose kubeconfig and every cluster needs re authentication.

Where Kubectx stores this, by platform

Windows
%USERPROFILE%\.kube\config

Holds clusters, contexts and users. Current context flips live here. Copy this file with tight permissions (600) to migrate machines.

macOS
~/.kube/config

Same kubeconfig layout as Windows. KUBECONFIG env can join multiple files with a colon separator. Kubens writes the namespace into the context entry.

Linux
~/.kube/config

Respects XDG only when configured. Default stays at ~/.kube. Keep the file out of shared dotfile repos unless secrets are stripped.

Frequently asked questions

What actually needs backing up for kubectx?

Back up ~/.kube/config. That single YAML holds clusters, users and contexts. Kubectx only flips the current-context pointer inside it.

Where do kubectx contexts come from?

Run kubectx to list contexts from kubeconfig, then kubens for namespaces. Both read the same file. No daemon or database sits behind them.

Notice an outdated path? Let us know.