Kubectl: Change Context
To change your active cluster, you don't need to re-enter API keys, re-download certs, or pray to the cloud gods. You just run:
So if you find yourself constantly typing -n my-namespace after every command, bake it into the context itself. kubectl change context
We’ve all been there. And the single most important command to break that curse is: kubectl config use-context . By default, kubectl doesn't care about your feelings—or your environment. It remembers the last cluster you touched. If you were troubleshooting in dev-east yesterday, you’re likely still pointing at dev-east today. To change your active cluster, you don't need
alias kctx='kubectl config current-context' But the real power move is seeing everything you can switch to: And the single most important command to break
kubectl config get-contexts This outputs a tidy table showing all your available clusters, their namespaces, and which one has the * (active) star next to it.
Now go forth, switch safely, and may your deployments always land where you intend. Have a "wrong context" horror story? Or a clever alias that saves you daily? Drop it in the comments—misery loves company.
kubectl config current-context This tells you the active cluster. I have this aliased in my .zshrc :