Typing kubectl get pods, kubectl describe, kubectl logs over and over gets tedious. k9s is a terminal UI that shows your cluster’s resources live, and lets you jump between pods, logs, shells and YAML with a few keystrokes. It works over SSH, uses your normal kubeconfig, and is one of the most popular Kubernetes tools for daily work.
Install
# Linux (amd64) from the release tarball
curl -sSL https://github.com/derailed/k9s/releases/latest/download/k9s_Linux_amd64.tar.gz | sudo tar -xz -C /usr/local/bin k9s
k9s version
# alternatives: brew install k9s, snap install k9s, or a distribution package where available
k9s reads ~/.kube/config (or $KUBECONFIG), just like kubectl. For k3s: export KUBECONFIG=/etc/rancher/k3s/k3s.yaml (as root, or copy it with the right permissions). For MicroK8s: microk8s config > ~/.kube/config. See k3s and MicroK8s.
Start
k9s # current context and namespace
k9s -n production # a specific namespace
k9s --context staging
k9s --readonly # disable modifying actions
Navigate with commands
Type : followed by a resource name, then Enter:
| Command | Shows |
|---|---|
:pods (or :po) |
Pods |
:deploy |
Deployments |
:svc |
Services |
:ing |
Ingresses |
:pvc |
PersistentVolumeClaims |
:events |
Events |
:nodes (:no) |
Nodes |
:ns |
Namespaces (select one with Enter) |
:ctx |
Contexts (switch clusters) |
:secrets, :cm |
Secrets, ConfigMaps |
/ filters the current list (for example /web). 0 shows all namespaces. Esc goes back.
Hotkeys on a selected resource
| Key | Action |
|---|---|
Enter |
Drill down (deployment → pods → containers) |
d |
Describe |
y |
View YAML |
e |
Edit (opens $EDITOR) |
l |
Logs (0 all, p previous container, w wrap, s autoscroll) |
s |
Shell into the container |
shift-f |
Port-forward |
ctrl-d |
Delete (asks for confirmation) |
ctrl-k |
Kill (force delete) |
s on a deployment |
Scale |
r on a deployment |
Rollout restart |
? |
Help: all hotkeys for this view |
The header shows the cluster, user, k9s version, and CPU and memory usage (with metrics-server).
Typical debugging flow
:pods, then/appto filter.- A pod in
CrashLoopBackOffis highlighted in colour. Pressdand read the events. - Press
l, thenpfor the previous container’s logs. - Fix the config, press
Esc, then:deploy, select it, and pressrto restart.
Useful features
- Pulses (
:pulses): a dashboard of cluster health. - XRay (
:xray deploy): a tree of related resources (deployment → replicasets → pods → containers). - Popeye (
:popeye): a cluster sanitiser report (misconfigurations, unused resources). - Benchmarks for HTTP services through port-forwards.
- Skins and custom aliases in
~/.config/k9s/.
Safety tips
- Use
--readonly(or a read-only kubeconfig) when looking around production. - Check the context in the header before deleting anything. Colour-code production contexts with a k9s skin.
- k9s does what your kubeconfig allows: RBAC still applies. See Kubernetes security basics.
Quick reference
| Task | Keys |
|---|---|
| Go to pods | :pods |
| Filter | /text |
| Describe / YAML | d / y |
| Logs (previous) | l, then p |
| Shell | s |
| Port-forward | shift-f |
| Switch namespace / cluster | :ns / :ctx |
Related: kubectl cheat sheet and Kubernetes deployments and services.