Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
Know it before you install
k9s uses your kubeconfig and your RBAC rights — it can do exactly what kubectl can do as you. You switch views with : commands (:pods, :deploy, :svc, :ns, :ctx …), filter with /, and act on the selected row with keys.
Install on RHEL and Ubuntu
Choose the newest release from github.com/derailed/k9s/releases:
curl -fsSLO https://github.com/derailed/k9s/releases/latest/download/k9s_Linux_amd64.tar.gz
tar -xzf k9s_Linux_amd64.tar.gz k9s
install -m 0755 k9s /usr/local/bin/k9s
k9s version
k9s info(Or install the k9s_linux_amd64.rpm / .deb from the same page.)
The keys you need
Start it (in a namespace, or read-only):
| Key | Action |
|---|---|
:pods, :deploy, :svc, :ing, :pvc, :events | Switch view (Tab completes). |
:ns / :ctx | Choose a namespace / a cluster context. |
0 | All namespaces. |
/text | Filter rows (/!text = not, /-l app=shop = label). |
Enter | Go into (Deployment → its Pods → containers). |
d | Describe. |
l | Logs (0 tail, w wrap, s autoscroll, p previous container). |
s | Shell into the container. |
Shift-f | Port-forward. |
e | Edit the YAML. y shows the YAML. |
r (on a Deployment) | Rollout restart. s = scale. |
Ctrl-d / Ctrl-k | Delete / kill (asks first). |
Esc / q / :q | Back / quit. |
? | Help for the current view. |
First configuration: safe defaults
k9s:
refreshRate: 2
readOnly: false
noExitOnCtrlC: true
ui:
headless: false
logoless: true
skin: ""
logger:
tail: 200
buffer: 5000
sinceSeconds: 300
skipLatestRevCheck: trueMake production read-only per context (k9s keeps per-cluster settings under its data folder) — or simply always start production with --readonly. Add an alias so the dangerous command is never the default:
echo "alias k9prod='k9s --context prod --readonly'" >> ~/.bashrc| Setting | Why |
|---|---|
--readonly / readOnly: true | No edit, delete or shell — safe for looking at production. |
logger.sinceSeconds / tail | Logs open fast and show the last minutes, not days. |
noExitOnCtrlC | A habit Ctrl-c does not close k9s by accident. |
Your own shortcuts in aliases.yaml (for example dp: apps/v1/deployments) and hotkeys.yaml (for example Shift-0 → pods).
Daily use: find problems fast
:podsthen/CrashLoopor sort by status (Shift-s) and restarts (Shift-r) — broken Pods come to the top.:eventssorted by time — the cluster tells you what is wrong (FailedScheduling, BackOff, Unhealthy).- On a Pod:
d(Events at the bottom) →l→p(previous container logs after a crash). :pulses— a live overview of the cluster health;:xray deploy shop— a tree of a Deployment with its ReplicaSets, Pods, containers, ConfigMaps and Secrets.:nodethenEnter— which Pods run on a node;Shift-c/Shift-msort by CPU/memory (needs metrics-server).
Real uses at work:
- Incident triage: crashing Pods, events, logs and a shell in seconds.
- Daily checks of deployments, rollouts and resource use.
- Teaching Kubernetes: you see how objects connect (xray).
Make it safe
Security checklist:
- k9s has your rights — use least-privilege RBAC users, not cluster-admin, for daily work.
--readonlyfor production unless you really must change something.- Watch the context name in the header before every action (
:ctx). - Shell sessions and port-forwards are powerful — close them when done.
- Keep k9s updated (it follows new Kubernetes versions).
Update and remove
Download the new release and replace the binary. Remove: rm /usr/local/bin/k9s ~/.config/k9s -r.
Fix common problems
| Problem | Cause | Fix |
|---|---|---|
Boom!! cannot connect to context / no data | Kubeconfig or login (token expired). | kubectl get nodes first; log in again (aws sso login, az login). |
Views are empty or show forbidden | RBAC: no list/watch rights there. | Use a namespace you may see; ask for read rights. |
CPU/memory columns show n/a | No metrics-server. | Install metrics-server in the cluster. |
| Keys do nothing (edit, delete) | Read-only mode. | That is the protection; start without --readonly only when needed. |
| Strange colours or broken lines | Terminal type or font. | Use a modern terminal; TERM=xterm-256color; try another skin. |
Next steps
- Command page: k9s, Command page: kubectl.
- At work: k9s and stern — find problems fast.
- The basics underneath: kubectl. Troubleshooting skills: CKA — Troubleshoot.
1How do you open k9s on production without any risk of changes?
2A Pod restarts again and again. Which keys show why?
d (describe → Events) and l then p (logs of the previous container).