Search code examples
kuberneteskubectl

How do you remove a kubernetes context?


I was following a tutorial on kubernetes and it told me to run the following commands:

kubectl config set-cluster --server=http://127.0.0.1:8080
kubectl config set-context local --cluster=local
kubectl config use-context local

Now when I run kubectl config view I see an entry for local:

contexts:
- context:
    cluster: local
    user: ""
  name: local

I was kind of curious about this so I ran the following command:

kubectl config set-context testorz --cluster=local

Now I see that when I run kubectl config view

How do I remove my "testorz" context?


Solution

  • You can kubectl config unset contexts.testorz to remove that entry.

    See http://kubernetes.io/docs/user-guide/kubectl/kubectl_config_unset/