Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 490
Ramon Balthazar Avatar asked Sep 15 '25 22:09

Ramon Balthazar


1 Answers

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.

like image 59
Arghya Sadhu Avatar answered Sep 17 '25 11:09

Arghya Sadhu