▶Prefer to watch? This short video runs this page's main commands in a real lab, with on-screen captions and no voiceover. Click to play, or watch it on YouTube.
k9s [flags]
k9s -n my-namespace
k9s is a terminal dashboard for Kubernetes. It shows your cluster live (pods, deployments,
nodes, logs) and lets you describe, edit, shell into, restart or delete things with single
keystrokes, instead of typing long kubectl commands. It uses the same kubeconfig as kubectl,
so it can do whatever your account is allowed to do. Be careful: one wrong key on the
wrong context can delete something real.
Install
brew install k9s # macOS and Linux (Homebrew)
sudo snap install k9s # Linux (snap)
go install github.com/derailed/k9s@latest # from source
winget install k9s | choco install k9s | scoop install k9s # Windows
Or download a release binary from github.com/derailed/k9s/releases and put it on your PATH.
docker run --rm -it -v ~/.kube/config:/root/.kube/config quay.io/derailed/k9s
k9s version # check what you have
Start it
k9s # current context and namespace
k9s -n kube-system # start in a namespace
k9s -A # all namespaces (--all-namespaces)
k9s --context prod-cluster # a specific context
k9s --kubeconfig ~/.kube/other # a specific kubeconfig
k9s -c deployments # start on a view (--command; pods, svc, nodes ...)
k9s --readonly # disable every write action (safe for browsing)
k9s --headless # hide the header
k9s --logoless # hide the logo
k9s --crumbsless # hide the breadcrumbs
k9s -l debug # log level (logs go to a file, see k9s info)
k9s info # show where config, logs and skins are stored
k9s --help
The screen
Header (top) Context, cluster, user, k9s and Kubernetes versions, CPU and memory, plus key hints
Main table The resources in the current view. The selected row is highlighted
Breadcrumbs Where you are (for example: pods > containers)
Command line Appears at the bottom when you press : or /
Move around
j / k or Down / Up Move down / up g / G Jump to top / bottom
Ctrl-F / Ctrl-B Page down / up Enter Drill into the selected item
Esc Go back / close a prompt ? Show every key for the current view
Ctrl-A List all available resource aliases (like :pod, :svc)
:q or Ctrl-C Quit
Switch views (press : then a name, then Enter)
:pods (:po) :deployments (:deploy) :services (:svc)
:namespaces (:ns) :nodes (:no) :configmaps (:cm)
:secrets (:sec) :ingresses (:ing) :statefulsets (:sts)
:daemonsets (:ds) :replicasets (:rs) :jobs :cronjobs (:cj)
:persistentvolumes (:pv) :persistentvolumeclaims (:pvc) :events (:ev)
:serviceaccounts (:sa) :roles :rolebindings :clusterroles :clusterrolebindings
:context (:ctx) Switch cluster context
:pulses Cluster health summary charts
:xray deploy Tree of a resource and everything it owns (deploy, pods, svc ...)
:popeye Cluster sanitizer report (needs Popeye support)
:alias List all aliases
:pods /nginx A view with a filter already applied
:pods kube-system A view in a specific namespace
Use the Tab key to autocomplete a command. Custom resources (CRDs) appear as views too.
Namespaces and contexts
:ns then Enter on a row Use that namespace
0 Show all namespaces
1 ... 9 Jump to a favorite namespace (numbers shown in the header)
:ctx then Enter on a row Switch to another cluster context
u (in the namespaces view) Use the selected namespace
Double-check the context name in the header before you do anything destructive.
Filter and search
/error Filter the table by text (regular expression; press Enter to lock it)
/!error Invert: hide rows that match
/-l app=web Filter by label selector
/-f web Fuzzy filter
Esc Clear the filter
/ in logs and YAML Search the text; n and N jump to the next and previous match
Common actions on the selected resource
Enter Drill down (deployment > pods > containers)
d Describe (like kubectl describe)
y View the YAML
e Edit the resource in your $EDITOR (saves back to the cluster)
l View logs (pods and containers)
p Logs of the previous container instance (after a crash)
s Shell into the container (pods). On deployments/statefulsets: scale
a Attach to the container
Shift-F Port-forward (opens a dialog for the ports)
f Show the active port-forwards (in the port-forward list)
r Restart the workload (deployments, statefulsets, daemonsets)
Ctrl-D Delete (asks for confirmation)
Ctrl-K Kill: delete right now, no grace period (asks for confirmation)
Space Mark or unmark a row (act on several at once)
Ctrl-Space Mark a range
Ctrl-\ Clear all marks
Shift-J Jump to the owner of a resource (pod to its deployment)
o Show which node a pod runs on
u Show what uses a secret or configmap (some views)
x Decode a secret (in the secrets view)
t Trigger a cronjob (in the cronjobs view)
Ctrl-Z Toggle showing only resources with errors (some versions)
Which keys exist depends on the resource type and k9s version: press ? to see the exact list.
Sorting and view options
Shift-N Sort by name Shift-A Sort by age
Shift-C Sort by CPU Shift-M Sort by memory
Shift-S Sort by status Shift-R Sort by ready
Press the same key again to flip ascending and descending.
Ctrl-W Toggle wide columns Ctrl-E Toggle the header
Logs view
l Open logs for the selected pod or container
0 Show logs since the beginning (tail)
1 Last 1 minute 2 Last 5 minutes 3 Last 15 minutes
4 Last 30 minutes 5 Last 1 hour
s Toggle autoscroll w Toggle line wrap t Toggle timestamps
f Full screen c Copy to the clipboard
m Mark a position (for reading later) Ctrl-S Save the log to a file
/ Search text in the log
p Switch to the previous container's logs
Esc Back to the pod list
For pods with several containers, choose the container first, or use the container view.
Shell into a container
Select the pod, then press s. k9s picks the container (or asks). Exit with exit or Ctrl-D.
Some minimal images have no shell. In that case use a debug container:
kubectl debug -it POD --image=busybox --target=CONTAINER
Health and cluster overview
:pulses Charts of pods, deployments, jobs and events over time
:xray deploy See an entire deployment tree with statuses
:popeye Scan the cluster for misconfigurations and wasteful settings
:nodes then d Describe a node: capacity, taints, conditions, pods
:events Recent cluster events (sort with Shift-A to see the newest)
:pods then Shift-C or Shift-M Find the CPU and memory hogs
Metrics (CPU and memory columns) need metrics-server installed in the cluster.
Configuration files (find the location with k9s info)
Usually ~/.config/k9s/ (or $XDG_CONFIG_HOME/k9s, or ~/Library/Application Support/k9s on macOS)
config.yaml Global settings: refresh rate, readOnly, UI options, log settings
aliases.yaml Your own command shortcuts
hotkeys.yaml Your own key bindings to jump to views
plugins.yaml Your own actions that run external commands
views.yaml Choose and order table columns per resource
skins/ Color themes
clusters/ Per-cluster settings (in some versions)
Aliases (~/.config/k9s/aliases.yaml)
aliases:
pp: v1/pods
dep: apps/v1/deployments
dc: apps/v1/deployments
Then type :pp to open the pods view.
Hot keys (~/.config/k9s/hotkeys.yaml)
hotKeys:
shift-0:
shortCut: Shift-0
description: Show the pods view
command: pods
Plugins (~/.config/k9s/plugins.yaml)
plugins:
stern:
shortCut: Shift-L
description: Tail logs with stern
scopes:
- pods
command: stern
background: false
args:
- --tail
- 50
- $NAME
- -n
- $NAMESPACE
Plugin variables include $NAMESPACE, $NAME, $POD, $CONTAINER and $CONTEXT. Restart k9s after editing.
Only add plugins you trust. They run commands on your machine with your cluster access.
Settings worth knowing (config.yaml)
k9s:
refreshRate: 2 # seconds between screen refreshes
readOnly: false # true disables all edit, delete and scale actions
noExitOnCtrlC: true # avoid quitting by accident with Ctrl-C
logger:
tail: 200
buffer: 5000
sinceSeconds: 300
textWrap: false
showTime: false
Skins: copy a theme into ~/.config/k9s/skins/ and set ui.skin in config.yaml to its file name.
Practical workflows
# Why is my pod crashing?
:pods then / to filter by name
d describe: read the Events at the bottom
l view logs (and p for the previous container's logs)
# Roll a deployment
:deploy select it, press r to restart, or s to scale, or e to edit
# Follow the logs of everything a deployment runs
:deploy Enter (shows its pods), select a pod, press l
# Find noisy or heavy pods
:pods Shift-C (CPU) or Shift-M (memory)
# Peek inside a secret
:secrets select it, press x to decode
# Reach an internal service from your laptop
:svc select it, Shift-F, choose ports, then open http://localhost:PORT
# Check the whole cluster quickly
:pulses then :nodes, :events
# Work on a different cluster without leaving k9s
:ctx Enter on the context you want
# Look at one namespace only
:ns Enter on it, or start with k9s -n my-namespace
# Safe browsing for a demo or on production
k9s --readonly
k9s vs kubectl and friends
kubectl The exact, scriptable command line. Use it in scripts and CI
k9s Live, interactive exploration and quick fixes
kubectx/kubens Quick context and namespace switching
stern Tail logs from many pods at once
lens / headlamp Graphical Kubernetes dashboards
kubectl get -w Simple live watch of a single resource type
Common problems
"Unable to connect to the cluster" Your kubeconfig or VPN is wrong: try kubectl get nodes first
Empty screen or no resources Wrong namespace: press 0 for all namespaces, or use :ns
"Forbidden" messages Your account lacks permission (RBAC) for that resource
CPU and memory columns are blank metrics-server is not installed or not ready
Edit does nothing or opens the wrong editor Set $EDITOR or $KUBE_EDITOR (for example export EDITOR=vim)
Screen is garbled Use a terminal with 256 colors and a UTF-8 locale; try TERM=xterm-256color
Cannot shell into a pod The image has no shell (scratch, distroless). Use kubectl debug instead
Keys behave differently k9s versions differ. Press ? to see the keys for your version and view
Config changes ignored Restart k9s. Check the config path with k9s info
Tips
Press ? in any view. It always shows the exact keys that work for that resource and your version.
Learn six things first: : (views), / (filter), d (describe), l (logs), s (shell), Esc (back).
Check the context name in the header before you press Ctrl-D or Ctrl-K. Production and staging can look identical.
Use k9s --readonly when you only want to look, or in shared sessions and demos.
Press 0 to see all namespaces, and use / to filter, instead of scrolling.
Sort by CPU or memory (Shift-C, Shift-M) to find heavy workloads fast, and by age (Shift-A) to find what changed recently.
Add aliases, hot keys and plugins for the things you do every day, such as a stern log tailer.
Use :xray and :pulses for the big picture, and :events to see what the cluster is complaining about.
k9s is a client. It never changes anything you could not do with kubectl and your own permissions.
Deleting a pod managed by a Deployment just recreates it. To stop it, scale the Deployment to 0 instead.