How to change users in kubectl?

4/27/2020

In my machine I have two kubectl users, my company's account and my personal account. I can confirm that by running kubectl config view.

I'm trying to access my company's cluster but kubectl is using to my personal credentials to authenticate. Which is causing an error, as expected.

How do I change to my company's account?

-- Ramon Balthazar
kubectl
kubernetes

1 Answer

4/27/2020

Users and clusters are tied to a context and you can change users and clusters by changing the context.

kubectl config use-context my-context-name

Above command sets the current context to my-context-name.Now when kubectl is used the user and cluster tied to my-context-name context will be used.

Check the docs for more details and various other available options.

-- Arghya Sadhu
Source: StackOverflow