Dismissile
Dismissile

Reputation: 33071

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?

Upvotes: 19

Views: 15943

Answers (2)

GopherM
GopherM

Reputation: 700

In case you are using kubectx you can do it like this

kubectx -d <NAME>
kubectx -d testorz

or to delete current active context

kubectx -d .

Upvotes: 3

CJ Cullen
CJ Cullen

Reputation: 5642

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

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

Upvotes: 29

Related Questions