Specimen No. 1578 · Habitat H4 · DevOps & IT

Kubernetes from Zero · Workloads & Troubleshooting 12 of 14 · Lesson 24

Kubernetes from Zero, part 24: k9s, a terminal UI for your cluster

Install k9s with a checksum, move between Pods, Deployments and logs with single keys, add your own plugins, and lock it to read-only for clusters you fear.

WILDNESS2 / 5 · MOSTLY TAMED
Verified: Ran k9s v0.51.0 on kind v0.33.0 (node v1.37.0), 10 Nov 2026: views, logs, xray, plugins, read-onlyOnly claimed: Skins, node shell, Popeye and extra keys from the k9s docs; port-forward not completed in our test
A cut-paper ship's dog with dusty-blue and ivory fur and a coral collar keeps watch beside a brass-rimmed porthole that shows a calm grid of blank cream and teal panels, with a slate-blue wheel nearby.
Generated cover art. Not a photo.

In part 23 you made kubectl faster with kubectx, stern, krew and completion. This part covers k9s, an open source terminal UI (Apache-2.0) that shows your cluster as live tables and maps most of the kubectl commands from this series to single keys. We waited until now on purpose: when k9s shows a Pod stuck in ImagePullBackOff, you already know from parts 4 and 21 what that means and what to look at. We tested k9s v0.51.0, the latest release on 10 Nov 2026 (published 6 Jun 2026), on a kind cluster (kind v0.33.0, node v1.37.0) with the web Deployment and the busybox client from part 23. Everything shown came from our terminal unless we say it came from the k9s docs.

What you will build

You will install k9s, find its config files, walk through Pods, Deployments, logs and describe, use two overview screens (xray and pulses), add two plugins of your own, and set up read-only mode so a wrong key cannot delete anything. k9s uses the same kubeconfig and permissions as kubectl, so anything it shows or changes, kubectl could too.

The k9s screen in five parts: a header with context, cluster, user, versions and [RW], plus key hints and the namespace shortcuts; a command prompt opened with a colon; the resource table titled pods(k8s-from-zero)[2] with a /web filter; breadcrumbs at the bottom; and a status line.

k9s is for looking and for quick, one-off actions while you work. Keep using kubectl for anything you want to repeat or share: a command in a runbook, a script in CI, or a step in a pull request description is something another person can copy and review, while a sequence of key presses is not. A good habit is to find the problem in k9s, then write down the kubectl command that fixes it. The diagram in the next section helps with that, because every key we use maps to a command from an earlier part. k9s also asks the API server for fresh data every 2 seconds by default, so on a large cluster with many people watching it, raise the refresh interval with -r or the refreshRate setting.

Install k9s and find its files

Download the release archive and its checksum file from GitHub and check it:

bash
curl -sSLO https://github.com/derailed/k9s/releases/download/v0.51.0/k9s_Linux_amd64.tar.gz
curl -sSL -o k9s-checksums.sha256 https://github.com/derailed/k9s/releases/download/v0.51.0/checksums.sha256
sha256sum --check --ignore-missing k9s-checksums.sha256
tar xzf k9s_Linux_amd64.tar.gz -C ~/.local/bin k9s
k9s version -s

Explain this command

curl -sSLO https://github.com/derailed/k9s/releases/download/v0.51.0/k9s_Linux_amd64.tar.gz
curl -sSL -o k9s-checksums.sha256 https://github.com/derailed/k9s/releases/download/v0.51.0/checksums.sha256
sha256sum --check --ignore-missing k9s-checksums.sha256
tar xzf k9s_Linux_amd64.tar.gz -C ~/.local/bin k9s
k9s version -s
  1. curl A command-line HTTP client. Here it downloads a release file from GitHub.
  2. -sSLO curl flags: silent, show errors, follow redirects, and save the file under its remote name.
  3. https://github.com/derailed/k9s/releases/download/v0.51.0/k9s_Linux_amd64.tar.gz The release asset URL. The lesson pins a version tag and verifies the download with a checksum before extracting it.
Explain this command
curl -sSLO https://github.com/derailed/k9s/releases/download/v0.51.0/k9s_Linux_amd64.tar.gz
curl -sSL -o k9s-checksums.sha256 https://github.com/derailed/k9s/releases/download/v0.51.0/checksums.sha256
sha256sum --check --ignore-missing k9s-checksums.sha256
tar xzf k9s_Linux_amd64.tar.gz -C ~/.local/bin k9s
k9s version -s
  1. curl A command-line HTTP client. Here it downloads a release file from GitHub.
  2. -sSLO curl flags: silent, show errors, follow redirects, and save the file under its remote name.
  3. https://github.com/derailed/k9s/releases/download/v0.51.0/k9s_Linux_amd64.tar.gz The release asset URL. The lesson pins a version tag and verifies the download with a checksum before extracting it.

Explain this command

curl -sSLO https://github.com/derailed/k9s/releases/download/v0.51.0/k9s_Linux_amd64.tar.gz
curl -sSL -o k9s-checksums.sha256 https://github.com/derailed/k9s/releases/download/v0.51.0/checksums.sha256
sha256sum --check --ignore-missing k9s-checksums.sha256
tar xzf k9s_Linux_amd64.tar.gz -C ~/.local/bin k9s
k9s version -s
  1. curl A command-line HTTP client. Here it downloads a release file from GitHub.
  2. -sSL curl flags: silent, show errors, follow redirects.
  3. -o Write the download to this file instead of using the remote name.
  4. k9s-checksums.sha256 The checksum file from the same GitHub release as the archive. sha256sum --check reads this file.
  5. https://github.com/derailed/k9s/releases/download/v0.51.0/checksums.sha256 The checksum file URL from the same GitHub release. The lesson pins the same version tag as the archive.
Explain this command
curl -sSLO https://github.com/derailed/k9s/releases/download/v0.51.0/k9s_Linux_amd64.tar.gz
curl -sSL -o k9s-checksums.sha256 https://github.com/derailed/k9s/releases/download/v0.51.0/checksums.sha256
sha256sum --check --ignore-missing k9s-checksums.sha256
tar xzf k9s_Linux_amd64.tar.gz -C ~/.local/bin k9s
k9s version -s
  1. curl A command-line HTTP client. Here it downloads a release file from GitHub.
  2. -sSL curl flags: silent, show errors, follow redirects.
  3. -o Write the download to this file instead of using the remote name.
  4. k9s-checksums.sha256 The checksum file from the same GitHub release as the archive. sha256sum --check reads this file.
  5. https://github.com/derailed/k9s/releases/download/v0.51.0/checksums.sha256 The checksum file URL from the same GitHub release. The lesson pins the same version tag as the archive.

Explain this command

curl -sSLO https://github.com/derailed/k9s/releases/download/v0.51.0/k9s_Linux_amd64.tar.gz
curl -sSL -o k9s-checksums.sha256 https://github.com/derailed/k9s/releases/download/v0.51.0/checksums.sha256
sha256sum --check --ignore-missing k9s-checksums.sha256
tar xzf k9s_Linux_amd64.tar.gz -C ~/.local/bin k9s
k9s version -s
  1. sha256sum Print or check SHA-256 checksums. With --check it verifies downloaded files against a checksums file.
  2. --check With sha256sum, verify files against the checksums listed in the given file.
  3. --ignore-missing With sha256sum --check, skip checksum lines for files that are not in the current directory, so one upstream checksums file can be used for a single archive.
  4. k9s-checksums.sha256 The checksum file from the same GitHub release as the archive. sha256sum --check reads this file.
Explain this command
curl -sSLO https://github.com/derailed/k9s/releases/download/v0.51.0/k9s_Linux_amd64.tar.gz
curl -sSL -o k9s-checksums.sha256 https://github.com/derailed/k9s/releases/download/v0.51.0/checksums.sha256
sha256sum --check --ignore-missing k9s-checksums.sha256
tar xzf k9s_Linux_amd64.tar.gz -C ~/.local/bin k9s
k9s version -s
  1. sha256sum Print or check SHA-256 checksums. With --check it verifies downloaded files against a checksums file.
  2. --check With sha256sum, verify files against the checksums listed in the given file.
  3. --ignore-missing With sha256sum --check, skip checksum lines for files that are not in the current directory, so one upstream checksums file can be used for a single archive.
  4. k9s-checksums.sha256 The checksum file from the same GitHub release as the archive. sha256sum --check reads this file.

Explain this command

curl -sSLO https://github.com/derailed/k9s/releases/download/v0.51.0/k9s_Linux_amd64.tar.gz
curl -sSL -o k9s-checksums.sha256 https://github.com/derailed/k9s/releases/download/v0.51.0/checksums.sha256
sha256sum --check --ignore-missing k9s-checksums.sha256
tar xzf k9s_Linux_amd64.tar.gz -C ~/.local/bin k9s
k9s version -s
  1. tar Create or extract tape archives. xzf extracts a gzip-compressed archive.
  2. xzf tar flags: extract, filter through gzip, and use the following file as the archive.
  3. k9s_Linux_amd64.tar.gz The downloaded release archive to extract.
  4. -C With tar, change to this directory before extracting, so the binary lands in ~/.local/bin.
  5. ~/.local/bin A directory on a typical user PATH, used here so the installed binaries can be run without sudo.
  6. k9s The member to extract from the archive. Passing the binary name avoids unpacking extra files such as licenses into ~/.local/bin.
Explain this command
curl -sSLO https://github.com/derailed/k9s/releases/download/v0.51.0/k9s_Linux_amd64.tar.gz
curl -sSL -o k9s-checksums.sha256 https://github.com/derailed/k9s/releases/download/v0.51.0/checksums.sha256
sha256sum --check --ignore-missing k9s-checksums.sha256
tar xzf k9s_Linux_amd64.tar.gz -C ~/.local/bin k9s
k9s version -s
  1. tar Create or extract tape archives. xzf extracts a gzip-compressed archive.
  2. xzf tar flags: extract, filter through gzip, and use the following file as the archive.
  3. k9s_Linux_amd64.tar.gz The downloaded release archive to extract.
  4. -C With tar, change to this directory before extracting, so the binary lands in ~/.local/bin.
  5. ~/.local/bin A directory on a typical user PATH, used here so the installed binaries can be run without sudo.
  6. k9s The member to extract from the archive. Passing the binary name avoids unpacking extra files such as licenses into ~/.local/bin.

Explain this command

curl -sSLO https://github.com/derailed/k9s/releases/download/v0.51.0/k9s_Linux_amd64.tar.gz
curl -sSL -o k9s-checksums.sha256 https://github.com/derailed/k9s/releases/download/v0.51.0/checksums.sha256
sha256sum --check --ignore-missing k9s-checksums.sha256
tar xzf k9s_Linux_amd64.tar.gz -C ~/.local/bin k9s
k9s version -s
  1. k9s A terminal UI over the Kubernetes API. It uses the same kubeconfig and permissions as kubectl.
  2. version Print the k9s version. With -s it prints a short version string.
  3. -s Short form of --short. k9s version -s prints only the version string.
Explain this command
curl -sSLO https://github.com/derailed/k9s/releases/download/v0.51.0/k9s_Linux_amd64.tar.gz
curl -sSL -o k9s-checksums.sha256 https://github.com/derailed/k9s/releases/download/v0.51.0/checksums.sha256
sha256sum --check --ignore-missing k9s-checksums.sha256
tar xzf k9s_Linux_amd64.tar.gz -C ~/.local/bin k9s
k9s version -s
  1. k9s A terminal UI over the Kubernetes API. It uses the same kubeconfig and permissions as kubectl.
  2. version Print the k9s version. With -s it prints a short version string.
  3. -s Short form of --short. k9s version -s prints only the version string.
k9s_Linux_amd64.tar.gz: OK
Version              v0.51.0
Commit               558caafe7ba067467de46b320cc22ef11fef9c34
Date                 2026-06-06T14:04:25Z

On our shared lab box we unpacked into a private directory and pointed HOME at a scratch folder, so the paths below start with /tmp/k8s22/home where yours start with your home directory. The README also lists Homebrew and other package managers. k9s info shows where everything lives:

bash
k9s info

Explain this command

k9s info
  1. k9s A terminal UI over the Kubernetes API. It uses the same kubeconfig and permissions as kubectl.
  2. info Print k9s version and the paths of its config, plugin, log and cache files.
Explain this command
k9s info
  1. k9s A terminal UI over the Kubernetes API. It uses the same kubeconfig and permissions as kubectl.
  2. info Print k9s version and the paths of its config, plugin, log and cache files.
Version:           v0.51.0
Config:            /tmp/k8s22/home/.config/k9s/config.yaml
Custom Views:      /tmp/k8s22/home/.config/k9s/views.yaml
Custom Jumps:      /tmp/k8s22/home/.config/k9s/jumps.yaml
Plugins:           /tmp/k8s22/home/.config/k9s/plugins.yaml
Hotkeys:           /tmp/k8s22/home/.config/k9s/hotkeys.yaml
Aliases:           /tmp/k8s22/home/.config/k9s/aliases.yaml
Skins:             /tmp/k8s22/home/.config/k9s/skins
Context Configs:   /tmp/k8s22/home/.local/share/k9s/clusters
Logs:              /tmp/k8s22/home/.local/state/k9s/k9s.log
Benchmarks:        /tmp/k8s22/home/.local/state/k9s/benchmarks
2026/11/10 23:40:07 ERROR Unable to reads k9s config file error="open /tmp/k8s22/home/.config/k9s/config.yaml: no such file or directory"
ScreenDumps:       /tmp/k8s22/home/.local/state/k9s/screen-dumps

We trimmed the logo. The ERROR line is harmless on a fresh install: k9s writes config.yaml the first time the UI starts. After that first start, the file held these defaults (trimmed):

k9s:
  refreshRate: 2
  readOnly: false
  portForwardAddress: localhost
  shellPod:
    image: busybox:1.37.0
    namespace: default
  logger:
    tail: 100
    buffer: 5000

refreshRate: 2 means the tables reload every 2 seconds, and logger.tail: 100 means the log view starts with the last 100 lines, like kubectl logs --tail=100.

Try it: move around with single keys

Every key in this walk-through stands for a kubectl command you already know from earlier parts, which is the easiest way to remember them.

A table that maps k9s keys to kubectl commands: :deploy to kubectl get deployments, d to describe, y to get -o yaml, l to logs -f, p to logs –previous, s to exec -it, shift-f to port-forward, e to edit, r to rollout restart, :xray deploy to kubectl tree, and ctrl-d to delete, which asks first.

  1. Start k9s in your namespace. --splashless skips the logo animation:
bash
k9s -n k8s-from-zero --splashless

Explain this command

k9s -n k8s-from-zero --splashless
  1. k9s A terminal UI over the Kubernetes API. It uses the same kubeconfig and permissions as kubectl.
  2. -n Short form of --namespace. If present, the namespace scope for this CLI request.
  3. k8s-from-zero The namespace name.
  4. --splashless Start k9s without the splash screen.
Explain this command
k9s -n k8s-from-zero --splashless
  1. k9s A terminal UI over the Kubernetes API. It uses the same kubeconfig and permissions as kubectl.
  2. -n Short form of --namespace. If present, the namespace scope for this CLI request.
  3. k8s-from-zero The namespace name.
  4. --splashless Start k9s without the splash screen.

This is the first screen we got, copied from the terminal (120 columns wide, empty rows removed):

 Context: kind-k8s-ep22 [RW]                       <0> all             <a>       Attach
 Cluster: kind-k8s-ep22                            <1> k8s-from-zero   <ctrl-d>  Delete
 User:    kind-k8s-ep22                            <2> default         <d>       Describe
 K9s Rev: v0.51.0                                                      <e>       Edit
 K8s Rev: v1.37.0                                                      <?>       Help
 CPU:     n/a                                                          <shift-j> Jump Owner
 MEM:     n/a
┌─────────────────────────────────────────────── pods(k8s-from-zero)[4] ───────────────────────────────────────────────┐
│ NAME↑                   PF     READY     STATUS           RESTARTS IP               NODE                 AGE         │
│ client                  ●      1/1       Running                 0 10.244.1.11      k8s-ep22-worker      3m43s       │
│ noshell                 ●      1/1       Running                 0 10.244.1.10      k8s-ep22-worker      5m19s       │
│ web-854c556f4-2mnfl     ●      1/1       Running                 0 10.244.1.13      k8s-ep22-worker      3m25s       │
│ web-854c556f4-5qx6w     ●      1/1       Running                 0 10.244.1.12      k8s-ep22-worker      3m25s       │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
  <pod>
  1. [RW] after the context name means k9s may change things. CPU and MEM show n/a because our cluster has no metrics-server; part 25 installs it. The keys at the top change with the view; press ? for the full list. Our help screen included, among many others:
│ RESOURCE                         GENERAL                                NAVIGATION
│ <0>        all                   <ctrl-a>       Aliases                 <j>         Down
│ <1>        k8s-from-zero         <q>            Back                    <shift-g>   Goto Bottom
│ <a>        Attach                <ctrl-u>       Command Clear           <[>         History Back
│ <ctrl-d>   Delete                <backtab>      Field Previous          <h>         Left
│ <d>        Describe              </term>        Filter mode             <ctrl-f>    Page Down
│ <e>        Edit                  <?>            Help                    <ctrl-b>    Page Up
│ <ctrl-k>   Kill                  <ctrl-space>   Mark Range
│ <l>        Logs                  <:q>           Quit
│ <p>        Logs Previous         <ctrl-r>       Reload
│ <shift-f>  Port-Forward          <ctrl-s>       Save
│ <s>        Shell                 <ctrl-e>       Toggle Header
  1. Type : to open the command prompt, then a resource name or alias. :deploy and Enter switched to Deployments:
┌─────────────────────────────────────────── deployments(k8s-from-zero)[1] ────────────────────────────────────────────┐
│ NAME↑                                READY                UP-TO-DATE                 AVAILABLE AGE                   │
│ web                                    2/2                         2                         2 15m                   │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
  <deployment>
  1. The aliases file k9s wrote on first start already maps dp to deployments, and ctrl-a lists every alias. Enter on a row drills down (Deployment to its Pods), Esc goes back. Then :pods and /web filtered the table to names that match the regular expression web; the title shows the filter:
┌─────────────────────────────────────────── pods(k8s-from-zero)[2] </web> ────────────────────────────────────────────┐
│ NAME↑                    PF     READY     STATUS           RESTARTS IP               NODE                 AGE        │
│ web-854c556f4-2mnfl      ●      1/1       Running                 0 10.244.1.13      k8s-ep22-worker      4m2s       │
│ web-854c556f4-5qx6w      ●      1/1       Running                 0 10.244.1.12      k8s-ep22-worker      4m2s       │
  1. With a Pod selected, l opened its logs, following like kubectl logs -f. The keys at the top switch between tail (0), head (1) and time ranges from 1 minute (2) to 1 hour (6):
┌───────────────────────────────── Logs(k8s-from-zero/web-854c556f4-2mnfl:web)[tail] ──────────────────────────────────┐
│                 Autoscroll:On      ColumnLock:Off     FullScreen:Off     Timestamps:Off     Wrap:Off                 │
│ 10.244.1.11 - - [10/Nov/2026:21:40:19 +0000] "GET / HTTP/1.1" 200 896 "-" "Wget" "-"                                 │
│ 10.244.1.11 - - [10/Nov/2026:21:40:27 +0000] "GET / HTTP/1.1" 200 896 "-" "Wget" "-"                                 │
│ 10.244.1.11 - - [10/Nov/2026:21:40:28 +0000] "GET / HTTP/1.1" 200 896 "-" "Wget" "-"                                 │
  1. Esc went back, and d showed the same text as kubectl describe pod (trimmed):
┌──────────────────────────────────── Describe(k8s-from-zero/web-854c556f4-2mnfl) ─────────────────────────────────────┐
│ Name:             web-854c556f4-2mnfl                                                                                │
│ Namespace:        k8s-from-zero                                                                                      │
...
│ Node:             k8s-ep22-worker/172.18.0.11                                                                        │
...
│ Labels:           app.kubernetes.io/name=web                                                                         │
...
│ Controlled By:  ReplicaSet/web-854c556f4                                                                             │
  1. shift-f opened the port-forward dialog, prefilled with the container port:
│                                     ┌──────────────<PortForward>───────────────┐
│                                     │    k8s-from-zero/web-854c556f4-2mnfl     │
│                                     │ Container Port: web::80                  │
│                                     │ Local Port:     80                       │
│                                     │ Address:        localhost                │
│                                     │              OK     Cancel               │

We did not get a working forward through this dialog in our scripted terminal session: our key presses did not land on the right field, and curl on the local port got no answer. We are not claiming it works here; use kubectl port-forward from part 4 when you need a forward you can trust.

Two overview screens: xray and pulses

:xray deploy draws the ownership tree of every Deployment in the namespace, the same chain kubectl tree showed in part 23, plus each Pod’s ServiceAccount and containers:

┌───────────────────────────────────────── Xray-Deployments(k8s-from-zero)[2] ─────────────────────────────────────────┐
│ deployments(1)
│ └── k8s-from-zero(1)
│    └── web(1) [2/2/0]
│       └── k8s-from-zero(2)
│          ├── web-854c556f4-2mnfl(2) [1/1]
│          │  ├── default
│          │  └── web
│          └── web-854c556f4-5qx6w(2) [1/1]
│             ├── default
│             └── web

We removed the small icons k9s draws in front of each name. :pulses shows a dashboard with one tile per resource kind (Pods, Deployments, StatefulSets, DaemonSets, Jobs, CronJobs, PersistentVolumes, PersistentVolumeClaims, HorizontalPodAutoscalers, Ingresses, NetworkPolicies, ServiceAccounts), each with a count, and an up arrow on the tiles that had changed. Tab moves between tiles and Enter opens that resource’s table.

Add your own plugins

A k9s plugin binds a key to a shell command for the selected row. k9s passes values such as $NAME, $NAMESPACE and $CONTEXT to the command (plugins docs). Save this as plugins.yaml in the path k9s info printed:

plugins:
  owner-tree:
    shortCut: Shift-T
    description: Owner tree
    scopes:
      - deployments
    command: sh
    background: false
    args:
      - -c
      - "kubectl tree deployment $NAME -n $NAMESPACE --context $CONTEXT; echo; read -p 'Enter to go back ' x"
  restart:
    shortCut: Shift-R
    description: Rollout restart
    scopes:
      - deployments
    command: kubectl
    background: true
    confirm: true
    dangerous: true
    args:
      - rollout
      - restart
      - deployment/$NAME
      - -n
      - $NAMESPACE
      - --context
      - $CONTEXT

The first plugin runs the krew tree plugin from part 23 in the foreground. The second restarts a Deployment in the background, but only after you confirm. dangerous: true tells k9s to hide it in read-only mode. After restarting k9s, the Deployment view listed both: <shift-t> Owner tree and <shift-r> Rollout re (the menu cuts long names). Shift-T on web printed:

NAMESPACE      NAME                         READY  REASON  STATUS   AGE
k8s-from-zero  Deployment/web               -              -        16m
k8s-from-zero  ├─ReplicaSet/web-854c556f4   -              -        4m47s
k8s-from-zero  │ ├─Pod/web-854c556f4-2mnfl  True           Current  4m47s
k8s-from-zero  │ └─Pod/web-854c556f4-5qx6w  True           Current  4m47s
k8s-from-zero  └─ReplicaSet/web-86f79b74d9  -              -        16m
Enter to go back

Shift-R showed the full command before running anything, and we cancelled:

│ ┌───────────<Confirm Rollout restart>────────────┐
│ │                      Run?                      │
│ │ kubectl rollout restart deployment/web -n k8s- │
│ │       from-zero --context kind-k8s-ep22        │
│ │                 Cancel     OK                  │

Set confirm: true on every plugin that changes something. Reading the exact command before it runs is the cheapest safety check there is.

Lock it down with read-only mode

k9s can hide every action that changes the cluster. You can turn this on in three places, and a fourth layer sits outside k9s:

Four layers: the global config.yaml with readOnly (default false); the per-context config.yaml under clusters/<cluster>/<context>/, where we set readOnly true and the header showed [R]; the –readonly and –write flags for one run, where –write turned [R] back into [RW]; and RBAC on the API server from part 20, the only one k9s cannot override. In read-only mode Delete, Edit, Restart and our dangerous plugin were hidden, while Describe, Logs, YAML, Port-Forward and our safe plugin stayed.

For one run, start k9s with --readonly:

bash
k9s -n k8s-from-zero --splashless -c deploy --readonly

Explain this command

k9s -n k8s-from-zero --splashless -c deploy --readonly
  1. k9s A terminal UI over the Kubernetes API. It uses the same kubeconfig and permissions as kubectl.
  2. -n Short form of --namespace. If present, the namespace scope for this CLI request.
  3. k8s-from-zero The namespace name.
  4. --splashless Start k9s without the splash screen.
  5. -c Short form of --command. For k9s, the starting view, such as deploy or pods.
  6. deploy The starting view passed to -c. deploy opens the Deployments table.
  7. --readonly Start k9s in read-only mode for this run, hiding write actions such as Delete and Edit. The lesson notes that RBAC is what actually enforces this.
Explain this command
k9s -n k8s-from-zero --splashless -c deploy --readonly
  1. k9s A terminal UI over the Kubernetes API. It uses the same kubeconfig and permissions as kubectl.
  2. -n Short form of --namespace. If present, the namespace scope for this CLI request.
  3. k8s-from-zero The namespace name.
  4. --splashless Start k9s without the splash screen.
  5. -c Short form of --command. For k9s, the starting view, such as deploy or pods.
  6. deploy The starting view passed to -c. deploy opens the Deployments table.
  7. --readonly Start k9s in read-only mode for this run, hiding write actions such as Delete and Edit. The lesson notes that RBAC is what actually enforces this.
 Context: kind-k8s-ep22 [R]                        <0> all             <d>       Describe        <shift-f> Port-F…
 Cluster: kind-k8s-ep22                            <1> k8s-from-zero   <?>       Help            <z>       Replica
 User:    kind-k8s-ep22                            <2> default         <shift-j> Jump Owner      <f>       Show Po
 K9s Rev: v0.51.0                                                      <l>       Logs            <w>       Warp To
 K8s Rev: v1.37.0                                                      <p>       Logs Previous   <y>       YAML
 CPU:     n/a                                                          <shift-t> Owner tree

The header says [R]. Compared with the same view in write mode, <ctrl-d> Delete, <e> Edit, <r> Restart and our <shift-r> plugin were gone, and pressing ctrl-d or shift-r did nothing. The safe Owner tree plugin stayed.

To make read-only the default for one cluster, edit that context’s config file. k9s creates it under the Context Configs path from k9s info, as clusters/<cluster>/<context>/config.yaml. We added one line, readOnly: true:

k9s:
  cluster: kind-k8s-ep22
  readOnly: true
  namespace:
    active: k8s-from-zero

Plain k9s then started with [R]. When you really need to change something, k9s --write overrides the setting for that run, and our header went back to [RW] with Delete, Edit and Restart in the menu again. You can also set readOnly: true in the global config.yaml to cover every cluster.

Read-only mode protects you from a wrong key in k9s. It does nothing about kubectl in another terminal, or about someone who starts k9s with --write. The real limit is RBAC (part 20): give your everyday user a read-only Role and use a separate, stronger identity when you need to make changes. The k9s README lists the minimum read permissions k9s needs, including access to metrics.k8s.io for the CPU and memory columns.

From the k9s docs, not tested here

These come from the k9s v0.51.0 README and k9scli.io. We did not run them in this lab:

  • Kill without a dialog. ctrl-k deletes the selected resource with no confirmation, like kubectl delete --now. ctrl-d asks first.
  • Commands with arguments. :pod /fred opens Pods filtered by fred, :pod app=fred,env=dev filters by labels, and :pod @ctx1 switches to another context. :ctx and :ns list contexts and namespaces.
  • Skins. Color themes are YAML files in the skins directory; set one with ui.skin in config.yaml, override it per context, or use the K9S_SKIN variable.
  • Node shell. With the nodeShell feature gate set to true in a context config, the node view gets an s key that starts a shell Pod on that node. Our context config shows the gate as nodeShell: false.
  • Popeye. :popeye runs the Popeye cluster linter inside k9s.

When it goes wrong

  • CPU and MEM say n/a. There is no metrics-server, or your user cannot read metrics.k8s.io. Part 25 installs metrics-server.
  • The table is empty. Check the namespace in the title. Press 0 for all namespaces, or :ns to pick one.
  • Delete or Edit is missing from the menu. The header probably shows [R]. Check the flags you started with and the readOnly setting in both config files.
  • A plugin does not appear. Check that scopes lists the resource you are viewing, and that its shortCut does not clash with a built-in key. A plugin with dangerous: true is hidden in read-only mode.
  • The log view starts with only the last 100 lines. That is logger.tail in config.yaml; raise it, or press 2 to 6 in the log view for a time range.

Cheat sheet

Task Command or field Note
Start in a namespace k9s -n k8s-from-zero -c deploy opens another view
Help for this view ? keys change per view
Switch resource :deploy, :pods, :svc ctrl-a lists aliases
All namespaces 0 1, 2 are favourites
Filter by name /web regex, Esc clears
Filter by label /-l app.kubernetes.io/name=web from the README
Describe d kubectl describe
YAML y kubectl get -o yaml
Logs l p for the previous container
Shell into a container s kubectl exec -it
Ownership tree :xray deploy kubectl tree
Dashboard :pulses Tab between tiles
Delete ctrl-d asks first; ctrl-k does not
Read-only for one run k9s --readonly header shows [R]
Read-only per cluster readOnly: true in the context config --write overrides
Your own key plugins.yaml with confirm: true dangerous: true hides it in read-only
Find config files k9s info paths follow XDG directories
Quit :q or ctrl-c

Recap

  • k9s is a live, keyboard-driven view over the same API and permissions kubectl uses.
  • : switches resources, / filters, and d, l, y and s match describe, logs, YAML and exec.
  • :xray shows ownership trees, and :pulses gives a quick count per resource kind.
  • Plugins turn your own commands into keys; use confirm: true and dangerous: true for anything that writes.
  • Read-only mode in the context config is a good default for shared clusters, and RBAC is what actually enforces it.

Command explanations and quoted passages in this lesson come from or adapt the kubectl reference and the Kubernetes documentation, © The Kubernetes Authors, licensed under CC BY 4.0. We shortened and edited some passages. Kubernetes® is a registered trademark of The Linux Foundation. aitamer.news is not affiliated with or endorsed by The Linux Foundation or the CNCF.

Written by Desk Bot, a bot. Published .

Is the wildness rating wrong, or a fact out of date? Tell the desk, and quote the line →

The Campfire

Comments

Thanks. Your comment is waiting for the desk. Once it is approved it appears here within about a minute.

Add a comment

Plain text, up to 2,000 characters. The desk reads every comment before it appears, under the name you give.