K9s

From G1Joshi/Agent-Skills · View interactive version

K9s is an AI agent skill from the GitHub repository G1Joshi/Agent-Skills. Expert K9s CLI assistance covering terminal Kubernetes cluster navigation, real-time log streaming, port forwarding, and pod debugging. Use when managing and troubleshooting Kubernetes clusters with speed.

How to use this skill

Skill file

K9s

K9s is a terminal UI (TUI) for Kubernetes. It is faster than clicking in a web dashboard and morediscoverable than raw kubectl.

When to Use

Quick Start

# Launch k9s with active kubeconfig
k9s

# Navigation shortcuts in k9s:
# :pods      - View all pods across namespaces
# :deploy    - View deployments
# :svc       - View services
# /<term>    - Filter items in active view
# l          - Stream logs for selected pod
# s          - Open shell (exec) inside selected container

Core Concepts

Custom Plugins Configuration (plugins.yaml)

Adding custom keyboard commands for rapid debugging:

# ~/.config/k9s/plugins.yaml
plugin:
  # Press 'Shift-D' on a deployment to view detailed rollout history
  rollout-history:
    shortCut: Shift-D
    confirm: false
    description: "Rollout History"
    scopes:
      - deployments
    command: kubectl
    background: false
    args:
      - rollout
      - history
      - deployment/$NAME
      - -n
      - $NAMESPACE

  # Press 'Shift-F' on a pod to launch interactive debug container
  debug-pod:
    shortCut: Shift-F
    confirm: true
    description: "Debug Pod"
    scopes:
      - pods
    command: kubectl
    background: false
    args:
      - debug
      - -it
      - $NAME
      - --image=nicolaka/netshoot
      - -n
      - $NAMESPACE

Essential Navigation & Keyboard Shortcuts

Accelerating cluster management:

Launching K9s with Custom Options

Starting K9s in secure modes:

# Launch in read-only mode to prevent accidental pod deletion in production
k9s --readonly --namespace production

# Specify custom context and refresh rate
k9s --context prod-eks-cluster --refresh 2

Common Patterns

Custom K9s Shortcuts and Plugins

Problem: Frequently running custom kubectl commands across different namespaces.

Solution: Define custom plugins in ~/.config/k9s/plugin.yaml.

# ~/.config/k9s/plugin.yaml
plugin:
  raw-logs:
    shortCut: Shift-L
    description: "Tail logs without truncation"
    scopes:
      - pods
    command: kubectl
    background: false
    args:
      - logs
      - -f
      - $NAME
      - -n
      - $NAMESPACE
      - --context
      - $CONTEXT

Best Practices

Do:

Don't:

Troubleshooting

| Error | Cause | Solution |

| :--------------------------------------- | :----------------------------------------------------------------- | :---------------------------------------------------------------------------------------------- |

| Boom!! K9s cannot connect to cluster | Active kubeconfig context invalid or cluster endpoint unreachable. | Verify connection: kubectl cluster-info and switch context with kubectl config use-context. |

| Pod logs failing to stream in k9s | Pod container crashed or user lacks RBAC pods/log permission. | Check container status and verify cluster role permissions. |

| Terminal display corrupted / artifacts | Incompatible terminal terminfo or small terminal window. | Run export TERM=xterm-256color and maximize terminal window. |

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.