What it does
k9s shows your cluster live in the terminal. Type : and a resource name (:pods, :deploy, :svc, :events) to jump there; / filters; Enter goes inside. It uses your kubeconfig and your RBAC rights, like kubectl.
It is fast for troubleshooting: see a crashing pod, press l for logs, d to describe, s for a shell.
How to write it
k9s [OPTIONS]Options 17
Most used
Start options
Keys
Nothing matches this filter.
Examples 11
$ run as a normal user# run as root (or with sudo)
1Start in a namespace
k9s -n shop2Safe view on production
k9s --context prod --readonly3Start in the Deployments view
k9s -c deploy -A4Find crashing pods
k9s -n shop -c podsType
/Crashto filter, thenlfor the logs andpfor the logs before the restart.5Look at events of the namespace
k9s -n shop -c eventsSort by age with shift-a.
6Restart a deployment
k9s -n shop -c deploySelect it, press
r(rollout restart).7Port-forward to a service
k9s -n shop -c svcSelect it, press shift-f and choose the port.
8Change the context
k9s -c ctxSelect the cluster, press Enter.
9Where are the k9s config and logs?
k9s info10Use another kubeconfig file
k9s --kubeconfig ~/.kube/lab.yaml11Debug a k9s problem
k9s -l debug tail -f "$(k9s info | awk '/Logs/{print $2}')"
Nothing matches this filter.
Watch out
- k9s can delete and edit with one key; use
--readonlyor a read-only RBAC user on production. - It shows only what your RBAC allows; missing views often mean missing rights.
Files
~/.config/k9s/- Config, skins, aliases (see
k9s info).
Tips to remember
- Learn kubectl first (exams have no k9s), then use k9s for speed at work.
Exit codes
0 | Normal exit. |
1 | Error (for example the cluster cannot be reached). |