Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubectl how to rename a context

Tags:

I have many contexts, one for staging, one for production, and many for dev clusters. Copy and pasting the default cluster names is tedious and hard, especially over time. How can I rename them to make context switching easier?

like image 330
arshbot Avatar asked Jan 06 '20 03:01

arshbot


2 Answers

Renaming contexts is easy!

$ kubectl config rename-context old-name new-name 

Confirm the change by

$ kubectl config get-contexts  
like image 76
arshbot Avatar answered Sep 22 '22 12:09

arshbot


If you are using kubectx try

kubectx new-context-name=old-context-name 
like image 45
Most Wanted Avatar answered Sep 23 '22 12:09

Most Wanted