<p><code>kubectl config view</code> shows contexts and clusters corresponding to clusters that I have deleted.</p>

<p>How can I remove those entries?</p>

<p>The command</p>

<pre><code>kubectl config unset clusters
</code></pre>

<p>appears to delete all clusters. Is there a way to selectively delete cluster entries? What about contexts?</p>

Jeremy Lewi
<p><code>kubectl config unset</code> takes a dot-delimited path. You can delete cluster/context/user entries by name. E.g.</p>

<pre><code>kubectl config unset users.gke_project_zone_name

kubectl config unset contexts.aws_cluster1-kubernetes

kubectl config unset clusters.foobar-baz
</code></pre>

<p>Side note, if you teardown your cluster using <a href="https://github.com/kubernetes/kubernetes/blob/master/cluster/kube-down.sh"><code>cluster/kube-down.sh</code></a> (or <a href="https://cloud.google.com/container-engine/docs/clusters/operations#deleting_a_container_cluster">gcloud</a> if you use Container Engine), it will delete the associated kubeconfig entries. There is also a planned <code>kubectl config</code> <a href="https://github.com/kubernetes/kubernetes/issues/20605">rework</a> for a future release to make the commands more intuitive/usable/consistent.</p>
