Kubectl Config Set Context May 2026

# Set the --namespace flag for the CURRENT context kubectl config set-context --current --namespace=db-migration Your existing context is updated. Now, every kubectl get pods automatically scopes to db-migration . No more typing -n db-migration on every command. The Secret Sauce: Aliases for Speed The --current flag is powerful, but typing kubectl config set-context --current --namespace=foo is still a mouthful. Professional Kubernetes engineers treat their shell like a cockpit. Here are three aliases that will change your life:

Add this to your ~/.zshrc or ~/.bashrc : kubectl config set context

For example, create a context for production that automatically sets a strict namespace, but combine it with a shell prompt change. # Set the --namespace flag for the CURRENT