ahmedjama.com

Tech | Insights | Inspiration

Ahmed Jama

3-Minute Read

k9s

K9s is CLI application that is designed to interact with Kubernetes clusters. The project is opensource (github: https://github.com/derailed/k9s) and it’s aim is to make it easier to navigate, observe and manage application deployed in Kubernetes.

In this blog post I will step through installing k9s in a POSIX-oriented systems and hightlight how to use K9s to navigate a Kubernetes cluster find the relevant information.

Installing K9s on Ubuntu 20.04

There are few options to install k9s in Linux. The installation instructions can be found on the k9s installation page (https://k9scli.io/topics/install/). I used brew on Linux to keep things simple and straighforward. I didn’t have this on my Ubuntu 20.04 machine; so I needed to install this first before installing k9s.

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

$ echo 'eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)' >> $HOME/.profile

$ eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)

$ brew install gcc

$ brew install derailed/k9s/k9s

K9s tour

Without recreating the wheel here is a asciinema tour by https://asciinema.org/~kitesurfer showing k9s in action.

Some common k9s shortcuts

Below are some common shortcuts for navigating through your cluster using k9s.

 RESOURCE                               GENERAL                                   NAVIGATION                            HELP                                │
│ <0>              all                   <esc>               Back/Clear            <j>               Down                <ctrl-a>         Aliases           │
│ <1>              default               <ctrl-u>            Command Clear         <shift-g>         Goto Bottom         <?>              Help              │
│ <ctrl-l>         Bench Run/Stop        <:cmd>              Command mode          <g>               Goto Top                                               │
│ <c>              Copy                  <tab>               Field Next            <h>               Left                                                   │
│ <ctrl-d>         Delete                <backtab>           Field Previous        <ctrl-f>          Page Down                                              │
│ <d>              Describe              </term>             Filter mode           <ctrl-b>          Page Up                                                │
│ <e>              Edit                  <space>             Mark                  <l>               Right                                                  │
│ <?>              Help                  <ctrl-\>            Mark Clear            <k>               Up                                                     │
│ <l>              Logs                  <ctrl-space>        Mark Range                                                                                     │
│ <shift-l>        Logs Previous         <:q>                Quit                                                                                           │
│ <shift-f>        Port-Forward          <ctrl-r>            Reload                                                                                         │
│ <ctrl-r>         Refresh               <ctrl-s>            Save                                                                                           │
│ <shift-a>        Sort Age              <ctrl-e>            Toggle Header                                                                                  │
│ <shift-n>        Sort Name                                                                                                                                │
│ <shift-t>        Sort Type                                                                                                                                │
│ <ctrl-z>         Toggle Faults                                                                                                                            │
│ <ctrl-w>         Toggle Wide                                                                                                                              │
│ <enter>          View                                                                                                                                     │
│ <y>              YAML

K9s CLI options

K9s CLI comes with a view arguments that you can use to launch the tool with different configuration. For example if you want see all your cluster contexts type k9s -c ctx.

Here are some of the lists from the k9s docs page.

   # List all available CLI options
   k9s help
   # Get info about K9s runtime (logs, configs, etc..)
   k9s info
   # Run K9s in a given namespace.
   k9s -n mycoolns
   # Run K9s and launch in pod view via the pod command.
   k9s -c pod
   # Start K9s in a non default KubeConfig context
   k9s --context coolCtx
   # Start K9s in readonly mode - with all modification commands disabled
   k9s --readonly

Say Something

Comments

Nothing yet.

Recent Posts

categories

About

This blog is a space for exploring both the technical and thought-provoking aspects of technology, sharing insights and breaking down complex concepts in an accessible and engaging way.