K8S Utility II - Terminal UI K9S

This article was last updated on: February 7, 2024 pm


📜 introduction

  • Sharpen knives and do not chop wood by mistake
  • Better tools make good work

Like me,kubectl It is not very slippery, and the following situations are often encountered:

  • Forgot the order, knock first --help, and then knock the order, inefficient
  • Forgot to add -n Specify the namespace
  • Commands that are too long are often misremembered or mistyped, for example kubectl exec -it...
  • Logs and yaml cannot be copied out quickly
  • For CRD resources, you can’t remember the CRD type and can’t find the relevant information
  • You cannot grasp the health and monitoring status of the cluster

If your working machine (front machine, springboard machine, operating machine, bastion machine…) Just a Linux shell, not a desktop environment. Then I highly recommend you to use this K8S utility: Terminal UI K9S

🐾 Introduction to K9S

K9S: K9s is oneTerminal-based UIto interact with Kubernetes clusters. The goal of this project is to make it easier to navigate, observe, and manage deployed applications. K9s continuously monitors changes in Kubernetes and provides subsequent commands to interact with observed resources.


🖌️ K9S functionality

  • Information at your fingertips!
    • Track real-time activity of resources running in a Kubernetes cluster.
  • Standard resources or CRDs?
    • Work with Kubernetes standard resources and custom resource definitions (i.e., CRDs).
  • Cluster metrics
    • Track real-time metrics related to resources such as pods, containers, and nodes (nodes).
  • Popular with advanced users!
    • Provides standard cluster management commands, such as logging, scaling, port forwarding, and restart
    • Define your own command shortcutsfor quick navigation with command aliases and hotkeys.
    • k9s supports plugin extensions to create your own cluster commands.
    • Powerful filtering modes that allow users to drill down and view workload-related resources.
  • Error drillthrough
    • Errors that drill directly into cluster resources.
  • Skins and customizability
    • Define your own look and feel with K9s skins.
    • Customize/arrange the columns to display on a per-resource basis.
  • Narrow or wide?
    • Provides a toggle to view minimal or full resource definitions
  • Multi-resource view
    • Pass Pulses and XRay Views provide an overview of cluster resources.
  • We got your RBAC!
    • Supports viewing RBAC rules such as clusters/roles and their associated bindings.
    • Reverse lookup asserts what a user/group or ServiceAccount can do on the cluster.
  • Built-in benchmarking
    • You can benchmark HTTP services/pods directly from K9s to see how your application is performing and adjust resource requests/limits accordingly.
  • Resource graph traversal
    • K9s provides a simple traversal of Kubernetes resources and their associated resources.

🛠️ Installation.

Directly from release Download the corresponding version of the page and extract it to /usr/local/bin Can.

⌨️ Command.

Run directly after installation k9s, you will enter the UI interface, as shown below:

k9s 首页

👽️ Shortcut key.

Actions Command Notes
Displays the active keyboard mnemonic and help ?
Displays all available aliases and resources on the cluster ctrl-a or :alias
Exit K9s :q, ctrl-c
View Kubernetes resources by singular/plural, or short name :po⏎ Singular, plural, short name or alias such as accepted pod or pods
View Kubernetes resources in a given namespace :alias namespace⏎
Filter out the resource view for a given filter /filter⏎ Support for Regex2, such as` fred blee `to filter the resources named fred or blee
Reverse regular expression filter /! filter⏎ Keep allDoes not matchsomething. Log not implemented.
Filter resource views by tags /-l label-selector⏎
Fuzzy lookup for a given resource /-f filter⏎
Exit view/command/filter mode <esc>
Key mappings to describe, view, edit, logs,… d,v, e, l,…
View and switch to another Kubernetes context :ctx⏎
View and switch to another Kubernetes context :ctx context-name⏎
View and switch to another Kubernetes namespace :ns⏎
View all saved resources :screendump or sd⏎
To delete a resource (pressTABkey and enterEnter) ctrl-d
Kill a resource (no confirmation dialog!) ctrl-k
Toggle Wide Column ctrl-w Equivalent to kubectl ... -o wide
Toggle Error Status ctrl-z View resources with errors
Run pulses view :pulses or pu⏎
Run Popeye view :popeye or pop⏎ See https://popeyecli.io

Deep use

shortcut key

Spend 10-30 minutes to get familiar with the shortcut keys, and then - super cool, all kinds of quick entry, find, switch, see yaml, see log, scroll through logs, enter the shell, edit, copy…

It is highly recommended to take time to familiarize yourself and you will feel your efficiency skyrocket. 🤓🤓🤓


Its filtering function is very powerful, so you can locate resources very quickly, such as I want to see all the CRDs of traefik, as follows:


traefik crd

More filtering functions, you can try it yourself and study further.

Pulses - Monitor the dashboard

:pulse Enter this mode, this is a monitoring dashboard, as shown below:


You can see the current health of the cluster very intuitively - obviously my Events are abnormal now, press it directly 5⏎, press again ctrl-zTo view exception events:



XRay provides a relationship in the dimension of a Kubernetes resource, like an X-ray, transmitted to the inside of the resource. As shown in the following figure:


Take Traefik Deployment as an example, located in Kube-System NS, which starts one traefik-97b44b794-7qvzk Pod, pod has only one traefik container, via ServiceAccount traefik The secret is mounted traefik-token-r7vd2


Popeye scores the cluster and every resource within the cluster, from 0 to 100, and finally evaluates your cluster based on the score: A or C, and gives the specific reason.

As follows:


DaemonSet scored 0 because neither requests nor limits were specified:

DaemonSet 0 分原因

There are many reasons why the service gets 20 points, and even intimately consider the problem of expensive expenses:

Service 20 分 原因

🔐 Intuitive RBAC

RBAC’s yaml looks inconvenient, if there are more requirements for permissions, then K9S is absolutely easy to use and intuitive, as follows, traefik role has what permissions are clear at a glance: who, what, how.


✍ Summary.

K9S is oneTerminal-based K8S UIUsing it without a desktop and only a terminal can greatly improve your efficiency and your awareness of K8S.

It has a lot of powerful features, among them: Shortcuts, Filtering, Pulses, XRay, Popeye, RBAC These features must be given a try and experience soaring!

Let’s use it together~ 🤓🤓🤓

K8S Utility II - Terminal UI K9S
Posted on
November 12, 2021
Licensed under