For example, create a context for production that automatically sets a strict namespace, but combine it with a shell prompt change.
kubectl config set-context [NAME] --cluster=[CLUSTER] --user=[USER] --namespace=[NAMESPACE] Imagine you have a production cluster named prod-us-east and a user named prod-admin . You want a quick way to switch to the payment namespace. kubectl config set context
Now, when you run kubectl config use-context prod-payment , your terminal turns into a warning siren. Did you just modify your current context with the wrong namespace and forget what the original was? Don't panic. Kubernetes stores the original cluster and user information in the context. You can reset just the namespace: For example, create a context for production that
The root cause is almost always the same: Context blindness. You were looking at the wrong cluster or the wrong namespace. Enter the most underrated lifesaver in the Kubernetes CLI toolbox: . Now, when you run kubectl config use-context prod-payment