Kubectl Change Context _verified_ Access
| CURRENT | NAME | CLUSTER | NAMESPACE | |---------|--------------------|--------------------|-----------| | * | dev-local | kind-dev | default | | | staging-gcp | gke-staging | frontend | | | prod-aws | arn:aws:eks:... | prod | Here’s where most tutorials stop, but you shouldn’t. A context is actually a triple: (cluster, user, namespace) .
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:
But wait. That’s the production cluster name in the prompt. Your stomach drops. You just deployed a half-baked, debug-logging, "staging-only" image to the live environment. kubectl change context
The kubectl Context Shuffle: How to Stop Breaking Production (and Your Sanity)
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. | CURRENT | NAME | CLUSTER | NAMESPACE
kubectl config use-context <context-name> For example:
So if you find yourself constantly typing -n my-namespace after every command, bake it into the context itself. To change your active cluster, you don't need
kubectl config current-context This tells you the active cluster. I have this aliased in my .zshrc :