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 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: kubectl config set context
Add this to your ~/.zshrc or ~/.bashrc : For example, create a context for production that
Master this command. Alias it. Love it.
The syntax is deceptively simple:
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. No more typing -n db-migration on every command