Kubectl Set Current Context

kubectl config get-contexts

If you have a context named prod-cluster , switch to it by running: kubectl config use-context prod-cluster Use code with caution.

kubectl config use-context dev-cluster kubectl config set-context --current --namespace=monitoring kubectl set current context

alias kctx='kubectl config use-context'

kubectl config current-context

kubectl config set-context dev-context \ --cluster=my-cluster \ --user=dev-user \ --namespace=dev-space Use code with caution. : The nickname of the cluster API server. --user : The nickname of the user credentials.

The asterisk ( * ) indicates your currently active context. kubectl config get-contexts If you have a context

| Command | Purpose | |---------|---------| | kubectl config get-contexts | List all available contexts | | kubectl config current-context | Show the current context | | kubectl config use-context <name> | Set the current context | | kubectl config set-context <name> | Create or modify a context (does not switch to it) |

Before setting a context, you need to know the exact name of the context you wish to switch to. You can list all available contexts configured in your kubeconfig file by running: --user : The nickname of the user credentials

kubectl config get-contexts