kubectl config view
shows contexts and clusters corresponding to clusters that I have deleted.
How can I remove those entries?
The command
kubectl config unset clusters
appears to delete all clusters. Is there a way to selectively delete cluster entries? What about contexts?
4条答案
按热度按时间uajslkp61#
kubectl config unset
takes a dot-delimited path. You can delete cluster/context/user entries by name. E.g.Side note, if you teardown your cluster using
cluster/kube-down.sh
(or gcloud if you use Container Engine), it will delete the associated kubeconfig entries. There is also a plannedkubectl config
rework for a future release to make the commands more intuitive/usable/consistent.cotxawn72#
For clusters and contexts you can also do
There's nothing specific for users though, so you still have to do
kmb7vmvb3#
Run command below to get all contexts you have:
Delete context:
dfddblmv4#
与问题无关,但可能是一个有用的资源。
看一看kubectx + kubens: Power tools for kubectl。
它们使切换上下文和命名空间变得很容易+可以选择删除
更改上下文:
更改名称空间:
删除上下文: