Mauricio Belduque
Mauricio Belduque

Reputation: 431

How to leave a kubectl cluster from cli?

How can I disconnect from a kubernetes cluster from gitbash, I connected once and I can't "disconnect" or make the cluster name go away.

enter image description here

Upvotes: 13

Views: 11384

Answers (2)

Mohammad Reza Karimi
Mohammad Reza Karimi

Reputation: 2087

It's not connected, it's on your kubectl configs context, you can unset it or use (switch to) another context.

How to see existing contexts

kubectl config get-contexts

How to switch to another context

kubectl config use-context <context-name>

You may have taken context name from the last command,

e.g. if you've enabled Kubernetes on your docker-desktop, you can use its context with this command:

kubectl config use-context docker-desktop

How to unset

kubectl config unset current-context

If you unset your current context, you will not have any active context anymore and if you run commands like kubectl get pods you will get this error:

The connection to the server localhost:8080 was refused - did you specify the right host or port?

Upvotes: 6

Mauricio Belduque
Mauricio Belduque

Reputation: 431

Thanks a lot. really what I needed was to run the command:

kubectl config unset current-context

Upvotes: 20

Related Questions