Kubectl Hacks - Be productive

Kubectl Hacks - Be productive

- 3 mins

At Gojek, I have been playing around with kubernetes for a few months now. Spending more and more time with its command line interface — kubectl

This post talks about extending kubectl with few of the plugins that have been useful to me in day to day debugging/maintaining things on k8s.

Photo by Carl Heyerdahl on Unsplash

Note: I am using zsh, so some of them are ohmyzsh plugins

Lets go through them!

ohmyzsh kubectl

This plugins provides aliases for common kubectl commands. You can get complete list of aliases here — kubectl-aliases

Few examples

Image Kubectl aliases

kubectx + kubens — Power tools for kubectl (+ fzf )

If you work with multiple clusters or namespaces then this tool is a blessing.

Kubectx Kubens
kubectx kubens

It shortens

Along with fzf — A command-line fuzzy finder, it gives an interactive menu to select the context/namespace as shown above in gif

kube-ps1 or zsh-kubectl-prompt

When dealing with multiple contexts and namespaces, it becomes confusing to determine what is the current context/namespace you are working on.

You can check for the current context/namespace using kubectl config current-context and kubectl config view to determine current namespace. This is fine when you are not dealing with multiple contexts and don’t have to switch frequently.

But if you do, this can be a saviour when doing certain operations or debugging production incidents where you have to change contexts frequently. Any wrong step and you can end up doing destructive operations on wrong cluster.

kube-ps1 or zsh-kubectl-prompt adds context and namespace upfront in your prompt, so that you can be sure of cluster and namespace you are working on.

zsh-kubectl-prompt zsh-kubectl-prompt

kube-ps1 kube-ps1


A tiny bash script to tail multiple pod logs in single stream. It is simply kubectl logs -f but for multiple pods.

You can do regex matching on pods, view specific container logs or can simply give multiple pods. This tool comes in handy when debugging issues with our applications. kubetail kubetail in action


Kubespy tools help in observing Kubernetes resources in real time. This is useful when you want to keep a track of resources on various actions you perform.

checkout kubespy in action — kubespy kubespy observing deployment resource status changes

These were a small set of plugins that I use in day to day activities. K8s have its own plugin package manager named as krew. They have around 70 plugins — do check them out here

K9s - Kubernetes CLI To Manage Your Clusters In Style!

K9s provides a terminal UI to interact with your Kubernetes clusters. The aim of this project is to make it easier to navigate, observe and manage your applications in the wild. K9s continually watches Kubernetes for changes and offers subsequent commands to interact with your observed resources.

Let me know if these were useful to you as well. If you have any suggestions do comment!

Aditya Chowdhry

Aditya Chowdhry

Software Engineer

comments powered by Disqus
rss facebook twitter github youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora