logo

Cheatsheets - k9s

Last Updated: 2023-02-14

Official Website: https://k9scli.io/

Start k9s

# Use default kubeconfig
$ k9s

# Use non-default kubeconfig
$ k9s --kubeconfig /path/to/kubeconfig

# Use non-default context
$ k9s --context fooctx

# Readonly
$ k9s --readonly

Using k9s

List Resources

List a specific resource:

  • :<resource>: list Resources, e.g. :pod to list all pods.
  • :<resource> <namespace>: list Resources in a given namespace.

List all available resources:

  • :alias or Ctrl-a: list all available aliases and resources.
  • :crd: list all CRDs.

Filter

  • /<filter>: regex filter.
  • /!<filter>: inverse regex filter.
  • /-l <label>: filter by labels.
  • /-f <filter>: fuzzy match.

Choose namespace

Type :namespace, select the desired namespace by up or down key, press Enter to select.

Choose context

  • :ctx: list ctx, then select from the list.
  • :ctx <context>: swtich to the specified context.

Show Decrypted Secrets

Type :secrets to list the secrets, then

  • x to decrypt the secret.
  • Esc to leave the decrypted display.

Key mappingg

  • y: yaml.
  • d: describe.
  • v: view.
  • e: edit.
  • l: logs.
  • w: wrap.
  • r: auto-refresh.
  • Ctrl-d: delete.
  • Ctrl-k: kill (no confirmation).
  • Ctrl-w: toggle wide columns. (Equivalent to kubectl ... -o wide)
  • Ctrl-z: toggle error state

Quit

  • Esc: Bails out of view/command/filter mode.
  • :q or Ctrl-c: quit k9s.

Configure k9s

  • $XDG_CONFIG_HOME/k9s/config.yml: k9s config.
  • $XDG_CONFIG_HOME/k9s/alias.yml: define your own alias.
  • $XDG_CONFIG_HOME/k9s/hotkey.yml: define your own hotkeys.
  • $XDG_CONFIG_HOME/k9s/plugin.yml: manage plugins.