-
Notifications
You must be signed in to change notification settings - Fork 989
Closed
Labels
area/kubectlkind/featureCategorizes issue or PR as related to a new feature.Categorizes issue or PR as related to a new feature.priority/P3sig/cliCategorizes an issue or PR as relevant to SIG CLI.Categorizes an issue or PR as relevant to SIG CLI.
Description
Feature Request
When attempting to run scripts we sometimes want to create and use a "temporary" context that can be easily cleaned up afterward. (as opposed to appending the --server etc arguments to every command since they may be externally loaded)
e.g
...
$originalContext = $(kubectl config current-context)
kubectl config set-context tempcontext --user=tempuser --cluster=tempcluster
kubectl config use-context tempcontext
...
do some stuff
...
kubectl config use-context $originalContext
kubectl config delete-context tempcontext
kubectl config delete-cluster tempcluster
...etc
However the delete-context result may end up with warning: this removed your active context, use "kubectl config use-context" to select a different one if there was no original context set (lets say on a fresh machine). Although the context can start as "" in the config, there is no way to just set it to "" since kubectl config use-context with no context name results in an error due to "unexpected args"
It would be nice if we could either
- Use the
use-contextcommand and provide a null or empty context (or some--cleararg) - Or provide a
kubectl config clear-context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/kubectlkind/featureCategorizes issue or PR as related to a new feature.Categorizes issue or PR as related to a new feature.priority/P3sig/cliCategorizes an issue or PR as relevant to SIG CLI.Categorizes an issue or PR as relevant to SIG CLI.