General Questions
What are kubectx and kubens?
What are kubectx and kubens?
What's the difference between the bash and Go implementations?
What's the difference between the bash and Go implementations?
- Original implementation
- Small bash scripts
- Stable and proven
- Still maintained for compatibility
- Newer, cross-platform compatible
- Better performance
- Receives new features
- Available as binaries from the Releases page
- Recommended for new installations
Can I use kubectx and kubens as kubectl plugins?
Can I use kubectx and kubens as kubectl plugins?
kubectl ctxinstead ofkubectxkubectl nsinstead ofkubens
Do I need both kubectx and kubens?
Do I need both kubectx and kubens?
- Use kubectx if you work with multiple clusters
- Use kubens if you work with multiple namespaces within a cluster
- Use both if you work with multiple clusters and namespaces (most common)
Installation Questions
How do I install kubectx and kubens?
How do I install kubectx and kubens?
- Homebrew (recommended)
- Krew (kubectl plugin)
- Manual installation
How do I enable shell completion?
How do I enable shell completion?
Which installation method should I use?
Which installation method should I use?
Interactive Mode Questions
What is interactive mode and how do I enable it?
What is interactive mode and how do I enable it?
$PATH, kubectx and kubens will automatically use interactive mode when:- No arguments are provided
- Output is to a terminal (not piped)
- Type to fuzzy search
- Arrow keys to navigate
- Enter to select
- Multi-select for deletion (kubectx -d)
How do I disable interactive mode?
How do I disable interactive mode?
.bashrc, .zshrc, or shell configuration file.Temporarily disable for one command:
Pipe the output to another command:- Scripting and automation
- Preference for list view
- Remote sessions where fzf doesn’t work well
Can I use interactive mode in scripts?
Can I use interactive mode in scripts?
- Interactive mode is automatically disabled when output is piped
- Set
KUBECTX_IGNORE_FZF=1to ensure non-interactive behavior - Use explicit context/namespace names in scripts
Usage Questions
How do I rename a context with a long name?
How do I rename a context with a long name?
NEW_NAME=OLD_NAME:How do I switch back to the previous context/namespace?
How do I switch back to the previous context/namespace?
- argument:cd - in shell navigation.Can I delete multiple contexts at once?
Can I delete multiple contexts at once?
Does deleting a context remove the cluster configuration?
Does deleting a context remove the cluster configuration?
kubectx -d only deletes the context entry. The associated cluster and user entries remain in your kubeconfig.What gets deleted:- The context entry (mapping between cluster, user, and namespace)
- Cluster entry (server URL, certificate-authority, etc.)
- User entry (credentials, client certificates, etc.)
How do I use kubens with a namespace that doesn't exist yet?
How do I use kubens with a namespace that doesn't exist yet?
--force or -f flag:- Preparing configuration before namespace creation
- Automation scripts that create namespaces later
- Working in disconnected environments
What's the difference between 'kubectx -u' and 'kubectx -d'?
What's the difference between 'kubectx -u' and 'kubectx -d'?
kubectx --unset (or -u):- Clears the current-context preference
- Does not delete any context entries
- Requires
--contextflag for subsequent kubectl commands
kubectx -d (delete):- Permanently removes context entries from kubeconfig
- Cannot be undone without re-adding the context
- If you delete the current context, current-context becomes empty
Customization Questions
How do I customize the colors?
How do I customize the colors?
KUBECTX_CURRENT_FGCOLOR and KUBECTX_CURRENT_BGCOLOR environment variables:.bashrc, .zshrc, etc.) to make them permanent.See tput color codes for available colors.To disable colors entirely:Can I add context/namespace to my shell prompt?
Can I add context/namespace to my shell prompt?
Where are the state files stored?
Where are the state files stored?
- Default:
~/.kube/kubectx - Override:
$KUBECTX_STATE_DIR/kubectx - Contains: Name of the previous context
- Default:
~/.kube/kubens/ - Override:
$KUBECTX_STATE_DIR/kubens/ - Contains: One file per context, each storing the previous namespace for that context
Troubleshooting
Why isn't interactive mode working?
Why isn't interactive mode working?
Why isn't tab completion working?
Why isn't tab completion working?
- Homebrew: Should work automatically if shell completion is configured
- Krew: Does NOT include completions, install manually
- Manual: Follow the completion setup guide
I get 'context not found' or 'namespace not found' errors
I get 'context not found' or 'namespace not found' errors
Changes aren't persisting after I close my terminal
Changes aren't persisting after I close my terminal
-
You have write permissions to your kubeconfig:
-
You’re using a custom kubeconfig location:
- Another process is overwriting your kubeconfig
-
You’re in a different context than you think:
Integration Questions
Can I use kubectx/kubens in CI/CD pipelines?
Can I use kubectx/kubens in CI/CD pipelines?
kubectl config commands which may be more explicit for CI/CD:Are kubectx and kubens compatible with all kubectl versions?
Are kubectx and kubens compatible with all kubectl versions?
- All kubectl versions
- Any tool that uses kubeconfig (helm, k9s, etc.)
- Multiple kubeconfig files (via
$KUBECONFIGenvironment variable)
Do kubectx and kubens work with multiple kubeconfig files?
Do kubectx and kubens work with multiple kubeconfig files?
$KUBECONFIG environment variable:Still Have Questions?
If you didn’t find your answer here:- Check the GitHub Issues for similar questions
- Review the command reference for detailed usage
- Open a new issue on GitHub