Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

k9s

A full-screen terminal UI for Kubernetes: browse resources, read logs, open a shell and delete pods with a few keys.

Niveau
DevOps-tool
Groep
Containers en Kubernetes
Root nodig
Nee
Pakket
k9s

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

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.

Zo schrijf je het

k9s [OPTIONS]

Opties 17

Meest gebruikt

Start options

-n, --namespace NS
Start in a namespace.
-A, --all-namespaces
Start with all namespaces.
--context NAME
Use another kubeconfig context.
-c, --command RES
Start in a view (for example -c deploy).
--readonly
No delete, edit or shell (safe on production).
--kubeconfig FILE
Use another kubeconfig.
-l, --logLevel debug
Log level of k9s itself.
info
Show where k9s keeps config and logs.

Keys

: RES
Go to a resource view (pods, deploy, svc, ns, events, ctx).
/ TEXT
Filter the list.
l / p
Logs / previous logs of the pod.
d / y / e
Describe / YAML / edit.
s
Shell into the container.
shift-f
Port-forward.
ctrl-d / ctrl-k
Delete / kill.
0 / 1-9
All namespaces / favourite namespaces.
? / esc / ctrl-c
Help / back / quit.

Voorbeelden 11

$ als gewone gebruiker# als root (of met sudo)

  1. 1Start in a namespace

    k9s -n shop
  2. 2Safe view on production

    k9s --context prod --readonly
  3. 3Start in the Deployments view

    k9s -c deploy -A
  4. 4Find crashing pods

    k9s -n shop -c pods

    Type /Crash to filter, then l for the logs and p for the logs before the restart.

  5. 5Look at events of the namespace

    k9s -n shop -c events

    Sort by age with shift-a.

  6. 6Restart a deployment

    k9s -n shop -c deploy

    Select it, press r (rollout restart).

  7. 7Port-forward to a service

    k9s -n shop -c svc

    Select it, press shift-f and choose the port.

  8. 8Change the context

    k9s -c ctx

    Select the cluster, press Enter.

  9. 9Where are the k9s config and logs?

    k9s info
  10. 10Use another kubeconfig file

    k9s --kubeconfig ~/.kube/lab.yaml
  11. 11Debug a k9s problem

    k9s -l debug
    tail -f "$(k9s info | awk '/Logs/{print $2}')"

Let op

  • k9s can delete and edit with one key; use --readonly or a read-only RBAC user on production.
  • It shows only what your RBAC allows; missing views often mean missing rights.

Bestanden

~/.config/k9s/
Config, skins, aliases (see k9s info).

Tips om te onthouden

  • Learn kubectl first (exams have no k9s), then use k9s for speed at work.

Exitcodes

0Normal exit.
1Error (for example the cluster cannot be reached).

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man k9s