ScriptsApr 11, 2026·1 min read

k9s — Terminal UI for Managing Kubernetes Clusters in Style

k9s is a powerful terminal-based UI for Kubernetes. Navigate, observe, and manage your clusters with keyboard shortcuts — much faster than kubectl commands.

SC
Script Depot · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

# Install
brew install k9s                       # macOS
snap install k9s --devmode              # Linux
choco install k9s                       # Windows

# Run (uses current kubectl context)
k9s

Navigate with keyboard — much faster than typing kubectl commands.

Intro

k9s is a terminal-based UI to interact with your Kubernetes clusters. Built on top of the Kubernetes API, it provides a rich, keyboard-driven interface that makes navigating, observing, and managing Kubernetes resources incredibly fast and intuitive. Think of it as a "Midnight Commander for Kubernetes" — you'll never want to type kubectl again.

With 33.3K+ GitHub stars and Apache-2.0 license, k9s has become the essential companion tool for Kubernetes administrators and developers who prefer terminal interfaces over web UIs.

What k9s Does

  • Resource Navigation: Browse all Kubernetes resources with tab completion
  • Live Updates: Real-time resource updates without refreshing
  • Multi-Cluster: Switch between clusters and namespaces instantly
  • Logs & Shell: Stream logs and exec into pods directly
  • Port Forward: One-key port forwarding
  • Resource Editing: Edit YAML in your favorite editor
  • RBAC View: Check permissions and roles
  • Node Metrics: View CPU/memory usage per node/pod
  • Benchmarking: Built-in HTTP load testing for services
  • Custom Views: Save frequently used resource views
  • Skins: Customizable color themes
  • Plugins: Extend with custom commands and actions

Installation

Package Managers

# macOS
brew install k9s

# Linux
snap install k9s --devmode
# Or via binary
curl -sS https://webinstall.dev/k9s | bash

# Windows
choco install k9s
# Or scoop
scoop install k9s

# Docker
docker run --rm -it -v $KUBECONFIG:/root/.kube/config quay.io/derailed/k9s

From Source

go install github.com/derailed/k9s@latest

Basic Usage

Starting k9s

# Use current kubectl context
k9s

# Specify context
k9s --context my-cluster

# Start in specific namespace
k9s -n kube-system

# Read-only mode
k9s --readonly

# With custom refresh rate
k9s --refresh 2

Essential Keyboard Shortcuts

Navigation

:podShow pods
:svcShow services
:deployShow deployments
:nsShow namespaces
:nodeShow nodes
:cmShow configmaps
:secretShow secrets
:ingShow ingresses
:pvcShow persistent volume claims
:saShow service accounts
:cronjobShow cronjobs
:hpaShow horizontal pod autoscalers
:netpolShow network policies

Common Actions

d               — Describe resource
v               — View YAML
e               — Edit YAML (opens $EDITOR)
l               — View logs
s               — Shell into pod
:q or ctrl-c    — Quit / go back
?               — Show help
/Filter resources (fuzzy search)
Esc             — Clear filter
Enter           — Select / drill down
Space           — Toggle mark
r               — Refresh view
ctrl-d          — Delete resource (with confirmation)
ctrl-k          — Kill pod

Pod-Specific

l               — View logs
shift+l         — View previous container logs
s               — Shell into container
f               — Port forward
ctrl-k          — Kill pod (force delete)
shift+f         — Show port forwards

Context & Namespace

:ctx            — Switch context
:ns             — Switch namespace
:0View all namespaces

Pulses & Benchmarks

:pulse          — Cluster pulse (heartbeat view)
:bench          — Start HTTP benchmark
ctrl+b          — Toggle benchmark on service

Advanced Features

Custom Aliases

Create ~/.config/k9s/aliases.yaml:

aliases:
  po: pod
  dep: deployment
  svc: service
  cmap: configmap
  sec: secret
  # Custom shortcut
  prod: "-n production pod"

Use with :prod to show pods in production namespace.

Hotkeys

Create ~/.config/k9s/hotkeys.yaml:

hotKey:
  shift-0:
    shortCut: Shift-0
    description: Viewing all pods
    command: pods
  shift-1:
    shortCut: Shift-1
    description: Viewing services
    command: services

Plugins

Create ~/.config/k9s/plugin.yaml:

plugin:
  tail-logs:
    shortCut: Ctrl-L
    description: "Tail logs with grep"
    scopes:
      - po
    command: sh
    background: false
    args:
      - -c
      - "kubectl logs -f --tail=100 $NAME -n $NAMESPACE | less"

  debug-container:
    shortCut: Shift-D
    description: "Launch debug container"
    scopes:
      - po
    command: kubectl
    background: false
    args:
      - debug
      - -it
      - "$NAME"
      - --image=nicolaka/netshoot
      - --target=$NAME
      - -n
      - "$NAMESPACE"

Skins (Themes)

Create ~/.config/k9s/skins/dracula.yaml:

k9s:
  body:
    fgColor: "#F8F8F2"
    bgColor: "#282A36"
    logoColor: "#BD93F9"
  # ... more color settings

Set in config: skin: dracula

Views & Contexts

k9s remembers your views per context. Each kubectl context has its own state:

  • Last viewed resource
  • Active filters
  • Saved views
  • Custom columns

Productivity Tips

Filter Resources

/nginx          — Show resources matching "nginx"
/!systemExclude "system"

View Multiple Resources

:svc,pod        — Show both services and pods

Decoded Secrets

k9s can decode base64 secrets in real-time:

Navigate to secret → x (decode) → shows plaintext

Live Logs with Highlighting

Navigate to pod → l (logs)
/ — Filter logs by keyword
t — Toggle follow mode
Shift-T — Toggle timestamps
Shift-F — Show full log

k9s vs Alternatives

Feature k9s Lens kubectl OpenLens
Interface Terminal GUI CLI GUI
Speed Very fast Slow (GUI) Fast Slow (GUI)
Learning curve Medium Low High Low
Keyboard-driven Yes Partial Yes Partial
Multi-cluster Yes Yes Yes (contexts) Yes
Resource usage ~100MB ~500MB+ Negligible ~500MB+
Remote SSH Yes Limited Yes Limited
Best for CLI users, SRE GUI users Scripting OSS Lens

常见问题

Q: k9s 需要什么权限? A: k9s 使用你的 kubectl 配置和权限。如果 kubectl 能访问集群,k9s 就能访问。只读 RBAC 用户可以用 --readonly 模式防止意外修改。

Q: 可以在多个集群间切换吗? A: 可以。使用 :ctx 命令查看所有 kubectl contexts 并切换。k9s 会记住每个 context 的状态(上次浏览的资源、过滤条件等)。

Q: 如何查看 CPU/内存使用? A: 确保集群安装了 metrics-server(kubectl top 能工作),然后在 k9s 中按 :pod 查看 pods,会显示实时 CPU 和内存。按 :node 查看节点资源。

来源与致谢

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets