Ramon Balthazar
Ramon Balthazar

Reputation: 4260

How to change users in kubectl?

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?

Upvotes: 4

Views: 16967

Answers (1)

Arghya Sadhu
Arghya Sadhu

Reputation: 44559

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.

Upvotes: 8

Related Questions