Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 859
Dismissile Avatar asked Apr 27 '16 13:04

Dismissile


People also ask

How do I change the context of Kubernetes?

You can quickly switch between clusters by using the kubectl config use-context command. To use that command, though, you need to configure contexts in your kubeconfig. This can be done with the kubectl config set-context command.

Where is kubectl context stored?

KUBECONFIG and Context – The Theory When you first setup your Kubernetes cluster you created a config file likely stored in your $HOME/. kube directory. This is the KUBECONFIG file and it is used to store information about your connection to the Kubernetes cluster.

What is a Kubernetes context?

A Kubernetes context is used to group access parameters under an easily recognizable name in a kubeconfig file – a file used to configure access to clusters. It is the connection to a particular cluster used by kubectl. This concept only applies in the place where the kubectl command is run.

How do I remove a service from Kubernetes?

You can delete a StatefulSet in the same way you delete other resources in Kubernetes: use the kubectl delete command, and specify the StatefulSet either by file or by name. You may need to delete the associated headless service separately after the StatefulSet itself is deleted.


1 Answers

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

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

like image 165
CJ Cullen Avatar answered Sep 21 '22 09:09

CJ Cullen