Kubectl Config Set Context |top| ⚡

get_k8s_context() { echo "$(kubectl config current-context 2>/dev/null)" } PROMPT='$(get_k8s_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: kubectl config set context

# Unset the namespace override kubectl config set-context --current --namespace= That empty string removes the namespace pinning, reverting to the default namespace defined in the original context (usually default ). A fintech engineer once spent three hours debugging why a new pod wasn't appearing. He ran kubectl get pods repeatedly. Nothing. He restarted the deployment. Nothing. He yelled at the cloud provider. Kubernetes stores the original cluster and user information

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. He ran kubectl get pods repeatedly

We have all been there.

The syntax is deceptively simple: