Categories: Programming

How to switch to a different Kubernetes context or namespace?

To list available contexts:

kubectl config get-contexts

To show the current context:

kubectl config current-context

To switch to a new context:

kubectl config use-context my-cluster-name

To switch to a new namespace:

kubectl config set-context --current --namespace=my-namespace

See more at the kubectl Cheat Sheet.

Chinh Do

I occasionally blog about programming (.NET, Node.js, Java, PowerShell, React, Angular, JavaScript, etc), gadgets, etc. Follow me on Twitter for tips on those same topics. You can also find me on GitHub. See About for more info.

View Comments

Recent Posts

How to ssh into Kubernetes pod

kubectl exec -it <podname> -- sh To get a list of running pods in the…

2 years ago

How to Create a Soft Symbolic Link (symlink) in Unix/Linux

# Create a soft symbolic link from /mnt/original (file or folder) to ~/link ln -s…

4 years ago

How to Configure Git Username and Email Address

git config --global user.name "<your name>" git config --global user.email "<youremail@somewhere.com>" Related Commands Show current…

4 years ago

Getting the Last Monday for Any Month with TypeScript/JavaScript

TypeScript/JavaScript function getLastMonday(d: Date) { let d1 = new Date(d.getFullYear(), d.getMonth() + 1, 0); let…

5 years ago

How to View Raw SMTP Email Headers in Outlook

I had to do some SMTP relay troubleshooting and it wasn't obvious how to view…

5 years ago

Tips & Tricks for Changing the Design/Content of a WordPress Site

I spent a good part of the weekend on a re-design of a client's dental…

5 years ago