问题描述
kubectl config view
显示了与我已删除的集群相对应的上下文和集群.
kubectl config view
shows contexts and clusters corresponding to clusters that I have deleted.
如何删除这些条目?
命令
kubectl config unset clusters
似乎删除所有群集.有没有办法选择性地删除群集条目?上下文呢?
appears to delete all clusters. Is there a way to selectively delete cluster entries? What about contexts?
推荐答案
kubectl config unset
采用点分隔的路径.您可以按名称删除集群/上下文/用户条目.例如
kubectl config unset
takes a dot-delimited path. You can delete cluster/context/user entries by name. E.g.
kubectl config unset users.gke_project_zone_name
kubectl config unset contexts.aws_cluster1-kubernetes
kubectl config unset clusters.foobar-baz
旁注,如果您使用 cluster/kube-down.sh
(或 gcloud (如果您使用容器引擎),则会删除关联的kubeconfig条目.还有一个计划的kubectl config
返工,用于将来的发行版,以使命令更加直观/可用/一致.
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 planned kubectl config
rework for a future release to make the commands more intuitive/usable/consistent.
这篇关于如何从kubectl config中删除集群和上下文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!