How to set up a serious Kubernetes terminal

All the CLI tools a growing k8s nerd needs

Chris Cooney
May 22, 2019 · 4 min read

Kubernetes comes pre-packaged with an outstanding CLI. For basic operations, it works wonderfully. Alas, when one needs to do something quickly, complexity increases.

The Kubernetes community has built all sorts of web based tooling for monitoring your cluster — kube ops view, grafana etc. However, having a fully kitted terminal will rapidly speed up the time it takes to get to the root of an issue. It forms a fundamental part of your Swiss army knife.

The following is a very short list of open source tools that I’ve applied to my OSX terminal. When used together, they allow me to skip around my kubernetes cluster, quickly troubleshoot issues, and monitor behaviour. I’ve cut out lots of small little utilities and stuck to the tools that I find myself using every day.

Before any tools…


oh yes

I’m starting strong. K9s is the momma bear of CLI tools for kubernetes cluster. You can SSH straight into pods with a single key press, view logs, delete resources and more. It provides outstanding access for the most common operations you’ll be performing. This is a staple for any engineer using kubernetes.


kubectl config use-context my-context

But with this, there are some prerequisites:

  • You need to know the name of the cluster before you run.
  • There is another, similar set-context command that could trip you up.

kubectx presents a simpler alternative to this. If you run kubectx on its own, it will list out all of the contexts in your .kube/config file. You can then provide the name of the context you’re interested in:

kubectx my-context

No need to remember all the contexts, no need to manually check files and no possibility of getting the wrong command. Nice and simple. Combined with k9s, this offers a lot of navigability from your CLI with minimal key presses.

Edit: I originally stated that k9s could not support switching between contexts. A brilliant response from Fernand Galiana pointed out that with the :ctx command, this is possible.


kubens kube-system

Now all of your commands run against the kube-system namespace, by default. You can also run kubens without anything else to see a list of your namespaces.


kubectl <my-command>

To remove this, ps1 is a zsh plugin that will automatically show you your current context and namespace:

I’m pointing at my minikube context and the default namespace

Now you can see which namespace and context you’re pointing out without running a single command. It’s also highly configurable too — you can turn off namespace or context, if you’re only interested in one of them, or you can use kubeoff to disable the whole thing entirely.


This was the first few lines of a very long, detailed report.


I’m talking regularly about kubernetes, DevOps and much more on my twitter account.

This is no longer updated. Go to instead

Chris Cooney

Written by

[‘tech’, ‘insane rambling’].map(category => new Article(category))

This is no longer updated. Go to instead

More From Medium

More from

More from

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade