Terminal-based UI for interacting with Kubernetes clusters, providing real-time observation and management of cluster resources.
Table of Contents#
- Overview
- Installation
- Navigation and Commands
- Context and Cluster Switching
- Keyboard Shortcuts
- Filtering and Searching
- Configuration
- Plugins
- Skin Customization
- Troubleshooting
- See Also
- Sources
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 k9sManual 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/k9sOn macOS#
brew install derailed/k9s/k9sOn Windows#
# Chocolatey
choco install k9s
# Scoop
scoop install k9s
# winget
winget install Derailed.k9s3. 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#
| Command | Description |
|---|---|
:pod or :po | Switch to pods view |
:service or :svc | Switch to services view |
:deploy | Switch to deployments view |
:ds | Switch to DaemonSets view |
:sts | Switch to StatefulSets view |
:ns | Switch to namespaces view |
:node or :no | Switch to nodes view |
:cj | Switch to CronJobs view |
:job | Switch to Jobs view |
:cm | Switch to ConfigMaps view |
:sec or :secret | Switch to secrets view |
:ing | Switch to ingresses view |
:pv | Switch to PersistentVolumes view |
:pvc | Switch to PersistentVolumeClaims view |
:ctx or :context | Switch cluster context |
:alias | Show all available resource aliases |
:xray <resource> | Show resource dependency tree |
:pulse | Show cluster pulse (health overview) |
:popeye | Run 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 immediatelySet a default namespace for a context:
:ns - Open namespace list
Select a namespace and press Enter
K9s remembers the namespace per contextLaunch 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 --readonly5. Keyboard Shortcuts#
Global Shortcuts#
| Key | Action |
|---|---|
: | Open command prompt |
/ | Open filter/search |
? | Show help / available key bindings for current view |
Esc | Back / clear filter / close dialog |
Ctrl+a | Show all available resource aliases |
q or Ctrl+c | Quit K9s |
Resource Actions#
| Key | Action |
|---|---|
Enter | Drill into selected resource |
d | Describe the selected resource |
e | Edit the selected resource manifest (opens in $EDITOR or $K9S_EDITOR) |
y | Show YAML for the selected resource |
l | View logs for the selected pod/container |
s | Shell into the selected pod/container |
a | Attach to the selected container |
f | Port-forward the selected resource |
Ctrl+d | Delete the selected resource (with confirmation) |
Ctrl+k | Kill the selected resource (no confirmation) |
Ctrl+w | Toggle wide columns |
Ctrl+z | Toggle showing only error-state resources |
Log View Shortcuts#
| Key | Action |
|---|---|
w | Toggle line wrapping |
t | Toggle timestamps |
s | Toggle auto-scroll |
0-5 | Set log verbosity level |
c | Clear the log view |
f | Toggle full-screen log view |
Namespace Shortcuts#
| Key | Action |
|---|---|
0 | Show all namespaces |
1-9 | Quick 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 selectorLog 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 scrolling7. Configuration#
K9s stores configuration in $XDG_CONFIG_HOME/k9s/ (typically ~/.config/k9s/).
Key Configuration Files#
| File | Purpose |
|---|---|
config.yaml | Global K9s settings (default namespace, refresh rate, log settings) |
aliases.yaml | Custom command aliases |
hotkeys.yaml | Custom hotkey bindings |
plugins.yaml | Plugin definitions |
views/<context>.yaml | Per-context column customizations |
skins/<skin-name>.yaml | Skin/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-clusterExample 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: services8. 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
- --
- shPlugins 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: draculaCommunity-maintained skins are available at the K9s Skins repository.
Troubleshooting#
| Issue | Cause | Solution |
|---|---|---|
| K9s shows no resources | Wrong context or namespace selected | Press :ctx to verify context; press 0 to show all namespaces |
| Colors or UI elements are broken | Terminal does not support 256 colors or true color | Use a terminal with true color support; set TERM=xterm-256color |
| "Unauthorized" or "Forbidden" errors | Insufficient RBAC permissions for the current user | Verify permissions with kubectl auth can-i --list; contact cluster admin |
| K9s crashes on startup | Corrupted config or incompatible plugin | Delete ~/.config/k9s/config.yaml and restart; check plugin definitions |
| Shell into pod fails | Pod 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 empty | Container has not produced output yet, or wrong container selected | Select a different container; check if the pod is actually running |