K9s: The Kubernetes CLI You Should Already Be Using

K9s is the interactive CLI for Kubernetes that makes kubectl obsolete for daily use. Setup, commands, and workflows that change your day.

I've been using kubectl for years. I know it well, I have commands memorized, I have aliases for everything. And then I discovered k9s, and I wondered how I managed without it.

K9s is a TUI (text user interface) for Kubernetes. It runs in the terminal, but has an interactive interface with navigation, filters, quick actions. Imagine a mix between kubectl and Vim: powerful, fast, and once you learn the shortcuts you don't go back.

Why kubectl Isn't Enough

kubectl is fantastic for scripting and automation. But for interactive use it has limits:

  • You have to type complete commands every time
  • To see logs you have to open another window
  • Switching between different resources requires separate commands
  • No auto-refresh — you have to re-run to see changes

K9s solves all these problems. You have a live view of the cluster, navigate with keys, perform actions with shortcuts. It's kubectl on steroids for daily use.

Installation

# macOS
brew install derailed/k9s/k9s

# Linux (via webi)
curl -sS https://webi.sh/k9s | sh

# Linux (from binary)
# Download from https://github.com/derailed/k9s/releases

# Arch
pacman -S k9s

# Windows (via scoop)
scoop install k9s

Launch with:

k9s

It automatically uses the current context from your kubeconfig. To change context or namespace, you do it directly from inside k9s.

Basic Commands

K9s is designed for fast navigation. These are the commands I use most.

Resource Navigation

Type : followed by the resource type:

  • :pods or :po — list pods
  • :deploy — deployments
  • :svc — services
  • :ns — namespaces
  • :no — nodes
  • :sec — secrets
  • :cm — configmaps

You can use standard Kubernetes abbreviations. If you know kubectl, you already know the names.

Filters

Once in a view, / opens the filter. Type something and see only resources that match.

/nginx     # shows only resources with "nginx" in the name
/app=web   # filter by label
/-n prod   # only prod namespace (if in All Namespaces)

The filter is live — results update as you type.

Actions on Pods

With a pod selected:

  • l — log (live streaming)
  • s — shell into container
  • d — describe
  • y — show YAML
  • e — edit
  • ctrl-d — delete
  • p — port-forward

These shortcuts work on any resource, where applicable.

General Navigation

  • Enter — enter resource / show details
  • Esc — go back
  • ctrl-a — show all namespaces
  • :q — quit
  • ? — help

Logs: Where K9s Shines

Log management is where k9s won me over.

Select a pod, press l. Logs appear streaming, like kubectl logs -f but better:

  • Scroll with arrows or Page Up/Down
  • / to search in logs
  • w for line wrap
  • t to toggle timestamps
  • 0 to return to the end (live)
  • Esc to exit

If the pod has multiple containers, k9s asks which one you want to see. You can also press a to see all containers together, with prefix to distinguish them.

For previous logs (restarted container), press p instead of l.

Simplified Port Forward

How many times have you written kubectl port-forward svc/my-service 8080:80? With k9s:

  1. Go to :svc
  2. Select the service
  3. Press shift-f
  4. Choose ports

The port-forward stays active in the background. See all active forwards with :pf.

Changing Context and Namespace

:ctx shows all contexts in your kubeconfig. Select and press Enter to switch.

:ns shows namespaces. Select to change. Or use ctrl-a to see all resources in all namespaces.

Customization

K9s is configurable via YAML files. Config is in ~/.config/k9s/ (or ~/.k9s on some platforms).

Custom Skin

You can change colors by modifying ~/.config/k9s/skins/myskin.yaml:

k9s:
  body:
    fgColor: white
    bgColor: black
  frame:
    border:
      fgColor: dodgerblue

Activate with:

# ~/.config/k9s/config.yaml
k9s:
  ui:
    skin: myskin

Custom Aliases

Define shortcuts for custom resources:

# ~/.config/k9s/aliases.yaml
aliases:
  pp: v1/pods
  dp: apps/v1/deployments
  ing: networking.k8s.io/v1/ingresses

Now :pp shows pods, :dp deployments, etc.

Hotkeys

You can define custom actions:

# ~/.config/k9s/hotkeys.yaml
hotKeys:
  shift-r:
    shortCut: Shift-R
    description: Rollout restart
    command: kubectl rollout restart deploy $NAME -n $NAMESPACE

This adds an action that does a rollout restart of the selected deployment.

Plugins

K9s supports plugins for custom actions. Create files in ~/.config/k9s/plugins/:

# ~/.config/k9s/plugins/stern.yaml
plugins:
  stern:
    shortCut: Shift-L
    description: Stern logs
    scopes:
      - pods
    command: stern
    args:
      - $NAME
      - -n
      - $NAMESPACE

Now Shift-L on a pod launches stern for logs. You can integrate any CLI tool into your k9s workflow.

Daily Workflow

Here's how I typically use k9s.

Start of day: Launch k9s, :ctx to verify I'm in the right cluster, :pods with ctrl-a for a general view. Any pods in red? Investigate.

Debugging a problem: :pods, filter for the problematic app, l for logs. If needed, s for a shell and investigate directly in the container.

New deploy: Do apply from terminal, then in k9s watch the new pods spawning. See status in real-time without doing kubectl get pods -w.

Port-forward for testing: :svc, select, shift-f. Test locally. When done, :pf and delete the forward.

Troubleshooting events: :events shows cluster events. Filter for the interesting namespace, see what happened.

K9s vs Lens vs kubectl

Three tools, three use cases.

kubectl: Scripting, automation, CI/CD. When I need to put commands in a script, kubectl is the only option.

k9s: Daily interactive use from terminal. My main tool when working with Kubernetes. Fast, powerful, works anywhere there's a terminal.

Lens: When I need to show something to someone else, or when I prefer a graphical interface. Demos, pair programming, exploring new clusters.

In practice, k9s covers 80% of my time with Kubernetes. For the rest I use kubectl (automation) or Lens (specific cases).

Advanced Tips

Some tricks I've learned over time:

Resource benchmarking: :pulses shows real-time CPU/memory usage graphs. Useful for understanding if a pod is struggling.

XRay view: :xray deploy shows a hierarchical view deploy → replicaset → pod. Useful for understanding the structure.

YAML diff: When you edit a resource with e, k9s shows you the diff before applying. Handy to avoid mistakes.

Popeye (integrated sanitizer): :popeye launches a cluster audit and shows potential problems. Not perfect, but gives useful hints.

Benchmark: With b on a pod you can see HTTP metrics if the container exposes them. Useful for performance debugging.

Common Problems

K9s won't start, connection error: Verify kubectl works. K9s uses the same kubeconfig and context.

I don't see all resources: Check RBAC permissions. K9s only shows what you have permission to see.

Slow performance on large clusters: Use filters to limit what gets fetched. Avoid ctrl-a on clusters with thousands of resources.

Wrong colors: Your terminal might not support 256 colors. Try a different skin or check terminal settings.

Conclusion

K9s has changed how I work with Kubernetes daily. It's not a kubectl replacement — for scripting you still need that. But for all interactive work, k9s is simply better.

The initial investment is minimal: a few minutes to install, a few hours to learn basic commands. The return is significantly higher productivity every day you work with Kubernetes.

If you spend more than half an hour a day on interactive kubectl, do yourself a favor and try k9s. One week and you won't go back.

The terminal isn't dead. Sometimes it's just more powerful than a graphical interface.