K9s + Lazyvim match made in heaven...

Article Image

If you're like me, remembering all the kubectl commands can become quite a challenge. Although I use ArgoCD, Visual Studio Code and Lens for most of my day-to-day activities within Kubernetes. I do sometimes reach for the command line.

I still find this a struggle, remembering all the command line arguments or knowing what to write or the correct command to shell into a pod etc etc.

This is where K9s comes in. This is an amazing tool here is the site bio:

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

It really is a great tool I have only barely scratched the surface but if you're use to vim or nano then this tool is great. I would say vim users or folks who know how to get around in vim will find k9s the most useful as it uses similar keybinds for commands.

To install K9s you can do this with Homebrew on a Mac.

# Via Homebrew
 brew install derailed/k9s/k9s

As mentioned above K9s has a similar feel to Vim you can see a list of the commands and keybindings here. The developer who built K9s has everything well documented along with a video tutorial section.

Like vim most of the commands start with : to open up a dialog.

Here you're able to easily see nodes by just typing : then nodes

k9s-home

Easily edit a manifest with your chosen editor (LazyVim in my case) just by pressing e on a selected manifest.

k9s-lazyvim-edit

Shell into a pod just by pressing s no more:

kubectl exec -it --namespace=example some-pod -- bash -c

shell

Making K9s even better with Lazyvim

Now you have K9s installed, I believe the default editor is vim, you're able to change this by adding an EDITOR environment variable to your .zshrc (or similar) file. I have mine set to:

EDITOR=nvim

Allowing me to use NeoVim, which I turn into LazyVim.

LazyVim

LazyVim is a Neovim setup powered by 💤 lazy.nvim to make it easy to customize and extend your config.

The reason I use LazyVim is because I don't use vim all that much, and although I love tinkering, managing a set of config files for NeoVim just seems more of a hassle than it's worth. Therefore, I use LazyVim which comes bundled with everything I need to get started. Just like K9s LazyVim, although baked with features already, is highly customisable.

This is just the start, but I am hoping to use this more and more, it will be best to setup repos for your LazyVim and K9s configs just to make things easier when starting a new computer.