Terminal-based UI for interacting with Kubernetes clusters, providing real-time observation and management of cluster resources.


1. Overview#

K9s is a terminal-based UI that provides a rich, interactive experience for managing Kubernetes clusters. It continuously watches the cluster for changes and offers intuitive commands to interact with observed resources.

Core features:

  • Real-time cluster resource monitoring
  • Editing of resource manifests directly from the terminal
  • Shell access into pods and containers
  • Log viewing with search and filtering
  • Multi-cluster and multi-context management
  • Plugin system for extending functionality
  • Customizable skins and themes
  • Resource CRUD operations with keyboard shortcuts
  • Benchmark support for HTTP services

2. Installation#

On Linux#

Using a package manager:

# Arch Linux
sudo pacman -S k9s

# Homebrew (Linux/macOS)
brew install derailed/k9s/k9s

# Nix
nix-env -i k9s

Manual installation from GitHub releases:

# Download the latest release (check https://github.com/derailed/k9s/releases for current version)
wget https://github.com/derailed/k9s/releases/download/v0.50.6/k9s_Linux_amd64.tar.gz

# Extract and install
tar -xvf k9s_Linux_amd64.tar.gz
sudo install -o root -g root -m 0755 k9s /usr/local/bin/k9s

On macOS#

brew install derailed/k9s/k9s

On Windows#

# Chocolatey
choco install k9s

# Scoop
scoop install k9s

# winget
winget install Derailed.k9s

3. Navigation and Commands#

K9s uses a command-based navigation system. Press : to open the command prompt and type a resource name to switch views.

Common Resource Commands#

CommandDescription
:pod or :poSwitch to pods view
:service or :svcSwitch to services view
:deploySwitch to deployments view
:dsSwitch to DaemonSets view
:stsSwitch to StatefulSets view
:nsSwitch to namespaces view
:node or :noSwitch to nodes view
:cjSwitch to CronJobs view
:jobSwitch to Jobs view
:cmSwitch to ConfigMaps view
:sec or :secretSwitch to secrets view
:ingSwitch to ingresses view
:pvSwitch to PersistentVolumes view
:pvcSwitch to PersistentVolumeClaims view
:ctx or :contextSwitch cluster context
:aliasShow all available resource aliases
:xray <resource>Show resource dependency tree
:pulseShow cluster pulse (health overview)
:popeyeRun cluster sanitizer (if popeye is available)

Selection and Drilling Down#

Use arrow keys or j/k (vim-style) to navigate lists. Press Enter to drill into a selected resource (for example, selecting a pod shows its containers).

4. Context and Cluster Switching#

Switch between configured Kubernetes contexts without leaving K9s:

:ctx          - Open context list
               Use arrow keys to select, Enter to switch
               The selected context becomes active immediately

Set a default namespace for a context:

:ns           - Open namespace list
               Select a namespace and press Enter
               K9s remembers the namespace per context

Launch K9s with a specific context and namespace:

# Start with a specific context
k9s --context <context-name>

# Start with a specific namespace
k9s -n <namespace>

# Start in a specific resource view
k9s --command pod

# Read-only mode (no delete/edit operations)
k9s --readonly

5. Keyboard Shortcuts#

Global Shortcuts#

KeyAction
:Open command prompt
/Open filter/search
?Show help / available key bindings for current view
EscBack / clear filter / close dialog
Ctrl+aShow all available resource aliases
q or Ctrl+cQuit K9s

Resource Actions#

KeyAction
EnterDrill into selected resource
dDescribe the selected resource
eEdit the selected resource manifest (opens in $EDITOR or $K9S_EDITOR)
yShow YAML for the selected resource
lView logs for the selected pod/container
sShell into the selected pod/container
aAttach to the selected container
fPort-forward the selected resource
Ctrl+dDelete the selected resource (with confirmation)
Ctrl+kKill the selected resource (no confirmation)
Ctrl+wToggle wide columns
Ctrl+zToggle showing only error-state resources

Log View Shortcuts#

KeyAction
wToggle line wrapping
tToggle timestamps
sToggle auto-scroll
0-5Set log verbosity level
cClear the log view
fToggle full-screen log view

Namespace Shortcuts#

KeyAction
0Show all namespaces
1-9Quick switch to favorited namespaces

6. Filtering and Searching#

Resource Filtering#

Press / in any resource view to type a filter term. The list updates in real time.

/nginx           - Show only resources with "nginx" in the name
/!nginx          - Inverse filter: hide resources matching "nginx"
/-l app=web      - Filter by label selector
/-f status=Running - Filter by field selector

Log Searching#

In the log view, press / to search. The view highlights and scrolls to matching lines.

/error           - Search for "error" in logs
/&error          - Highlight all occurrences without scrolling

7. Configuration#

K9s stores configuration in $XDG_CONFIG_HOME/k9s/ (typically ~/.config/k9s/).

Key Configuration Files#

FilePurpose
config.yamlGlobal K9s settings (default namespace, refresh rate, log settings)
aliases.yamlCustom command aliases
hotkeys.yamlCustom hotkey bindings
plugins.yamlPlugin definitions
views/<context>.yamlPer-context column customizations
skins/<skin-name>.yamlSkin/theme definitions

Example config.yaml#

k9s:
  refreshRate: 2
  maxConnRetry: 5
  enableMouse: false
  headless: false
  logoless: false
  crumbsless: false
  readOnly: false
  noExitOnCtrlC: false
  ui:
    enableSkins: true
    skin: dracula
  logger:
    tail: 100
    buffer: 5000
    sinceSeconds: -1
    textWrap: false
    showTime: false
  currentContext: my-cluster
  currentCluster: my-cluster

Example hotkeys.yaml#

hotKeys:
  shift-1:
    shortCut: Shift-1
    description: View pods
    command: pods
  shift-2:
    shortCut: Shift-2
    description: View deployments
    command: deploy
  shift-3:
    shortCut: Shift-3
    description: View services
    command: services

8. Plugins#

K9s supports plugins to extend functionality. Plugins run external commands against selected resources.

Example plugins.yaml#

plugins:
  # View logs with stern (multi-pod log viewer)
  stern:
    shortCut: Ctrl-L
    description: "Stern logs"
    scopes:
      - pods
    command: stern
    background: false
    args:
      - --tail
      - "50"
      - $NAME
      - -n
      - $NAMESPACE

  # Open a debug container
  debug:
    shortCut: Shift-D
    description: "Debug container"
    scopes:
      - containers
    command: kubectl
    background: false
    args:
      - debug
      - -it
      - -n
      - $NAMESPACE
      - $POD
      - --target
      - $NAME
      - --image=busybox:latest
      - --
      - sh

Plugins are triggered using their assigned shortcut key when a matching resource is selected.

9. Skin Customization#

K9s supports skins to change the terminal color scheme. Skins are YAML files in the skins/ directory.

Example Skin (Dracula theme)#

# ~/.config/k9s/skins/dracula.yaml
k9s:
  body:
    fgColor: "#f8f8f2"
    bgColor: "#282a36"
    logoColor: "#bd93f9"
  prompt:
    fgColor: "#f8f8f2"
    bgColor: "#282a36"
    suggestColor: "#bd93f9"
  info:
    fgColor: "#ff79c6"
    sectionColor: "#f8f8f2"
  dialog:
    fgColor: "#f8f8f2"
    bgColor: "#44475a"
    buttonFgColor: "#f8f8f2"
    buttonBgColor: "#bd93f9"
    buttonFocusFgColor: "#f8f8f2"
    buttonFocusBgColor: "#ff79c6"
    labelFgColor: "#8be9fd"
    fieldFgColor: "#f8f8f2"
  frame:
    border:
      fgColor: "#6272a4"
      focusColor: "#bd93f9"
    menu:
      fgColor: "#f8f8f2"
      keyColor: "#ff79c6"
      numKeyColor: "#ff79c6"
    title:
      fgColor: "#bd93f9"
      bgColor: "#282a36"
      highlightColor: "#8be9fd"
      counterColor: "#bd93f9"
      filterColor: "#ff79c6"

To activate a skin, set it in config.yaml:

k9s:
  ui:
    enableSkins: true
    skin: dracula

Community-maintained skins are available at the K9s Skins repository.

Troubleshooting#

IssueCauseSolution
K9s shows no resourcesWrong context or namespace selectedPress :ctx to verify context; press 0 to show all namespaces
Colors or UI elements are brokenTerminal does not support 256 colors or true colorUse a terminal with true color support; set TERM=xterm-256color
"Unauthorized" or "Forbidden" errorsInsufficient RBAC permissions for the current userVerify permissions with kubectl auth can-i --list; contact cluster admin
K9s crashes on startupCorrupted config or incompatible pluginDelete ~/.config/k9s/config.yaml and restart; check plugin definitions
Shell into pod failsPod has no shell binary (/bin/sh or /bin/bash)Try :shell with a different command; use kubectl debug with a sidecar image
Log view is emptyContainer has not produced output yet, or wrong container selectedSelect a different container; check if the pod is actually running

See Also#

Sources#