Kubectl Set Current Context <Direct Link>
kubectl config use-context <context-name> | 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) | Example Workflow # List all contexts kubectl config get-contexts See current context kubectl config current-context Switch to a different context kubectl config use-context prod-cluster Verify the change kubectl config current-context Note on kubectl config set-context While set-context modifies or creates a context, it does not switch to it. You must follow with use-context to make it active:
kubectl config set-context my-context --namespace=my-ns kubectl config use-context my-context kubectl set current context
There is no direct kubectl set current context command. To change or set the current context, you use: kubectl config use-context <
Comments
0 commentsNo comments yet