Kubernetes:如何从kubectl配置中删除集群和上下文? [英] Kubernetes: How do I delete clusters and contexts from kubectl config?

查看:85
本文介绍了Kubernetes:如何从kubectl配置中删除集群和上下文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

kubectl配置视图显示了与我已删除的集群相对应的上下文和集群.

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配置 返工,用于将来的发行版以使命令更多直观/可用/一致.

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.

这篇关于Kubernetes:如何从kubectl配置中删除集群和上下文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆