huntermerritt

k0-kubernetes-debug

Use the k0 CLI to investigate Kubernetes clusters — find problem pods, pull full diagnostic context, and understand resource relationships.

huntermerritt 0 Updated 3w ago

Resources

13
GitHub

Install

npx skillscat add huntermerritt/k0

Install via the SkillsCat registry.

SKILL.md

k0 — Kubernetes Debug Skill

k0 is a CLI tool for investigating Kubernetes clusters. Use it to find problem pods, pull full diagnostic context, and understand resource relationships — all in a single command.

Prerequisites

This skill is designed to be used by a coding agent (Claude Code, Cursor, Copilot, etc.) that can execute shell commands directly. The agent should run k0 commands and analyze the output to diagnose issues.

Find k0:

which k0 || /usr/local/bin/k0 version

If not found, install via Homebrew:

brew tap huntermerritt/k0 && brew install k0

Or build from source in the repo root:

make build && export PATH="$PWD/bin:$PATH"

The binary reads ~/.kube/config by default. Pass --kubeconfig <path> to override.

Workflow: Finding and Diagnosing Issues

Step 1 — Get cluster overview

k0 dashboard

Shows node count, workload counts, CPU/memory utilization and packing efficiency.

Step 2 — Find problem pods

k0 pods                        # all namespaces
k0 pods --namespace=<ns>       # scoped to one namespace
k0 pods --output json          # machine-readable

Returns pods with: restarts > 0, CrashLoopBackOff, OOMKilled, ImagePullBackOff, non-zero exit codes, pending/failed phase, unschedulable, not-ready containers.

Step 3 — Full diagnostic context for a pod (the key command)

k0 pod <namespace>/<name>
k0 pod <namespace>/<name> --output json

This single command returns everything needed to diagnose a pod:

  • Pod metadata (phase, node, IP, age)
  • All detected issues
  • Container states, restart counts, last termination reason, resource requests/limits
  • Ownership chain: Pod → ReplicaSet → Deployment (with replica counts)
  • Services routing to the pod (ClusterIP, ports)
  • Ingresses routing to those services (host, path, ingress class)
  • ConfigMaps and Secrets referenced via env or volume
  • Volume mounts (type and source)
  • Recent Kubernetes events filtered to this pod (warnings highlighted)
  • Last 100 lines of logs per container

Step 4 — Tail logs directly

k0 logs <namespace>/<name>                  # all containers
k0 logs <namespace>/<name> --container=<c>  # specific container

All Commands

k0 dashboard              Cluster stats and utilization
k0 nodes                  Node table with CPU/mem utilization
k0 namespaces             List all namespaces
k0 pods [-n <ns>]         Problem pods (restarts, errors, unhealthy)
k0 pod <ns>/<name>        Full pod diagnostic (ownership, events, logs)
k0 logs <ns>/<name>       Tail recent logs from a problem pod
k0 contexts               List kubecontexts
k0 use-context <name>     Switch active context
k0 serve                  Start web dashboard on :8080

All commands accept:

  • --kubeconfig <path> — override default ~/.kube/config
  • --output json / -o json — JSON output for programmatic use

Diagnostic Patterns

Pod is restarting repeatedly

k0 pod <ns>/<name>

Look at: ISSUES (exit code, reason), CONTAINERS (last state), EVENTS (OOMKilled/BackOff), LOGS (last lines before crash).

Pod stuck Pending

k0 pod <ns>/<name>

Look at: EVENTS (FailedScheduling, insufficient resources), CONDITIONS (PodScheduled=False).

Service not reachable

k0 pod <ns>/<name>

Look at: SERVICES (is a service selecting this pod?), INGRESSES (is the ingress rule correct?), CONTAINERS (is the container actually ready?).

Deployment not rolling out

k0 pods --namespace=<ns>
k0 pod <ns>/<name>

Look at: OWNERSHIP (Deployment ready/desired counts), EVENTS (image pull errors, resource limits).

Secrets or config missing

k0 pod <ns>/<name>

Look at: CONFIGMAPS, SECRETS (what is referenced), EVENTS (failed to mount, secret not found).

Example Session

# Find what's broken
$ k0 pods
NAME                                    NAMESPACE   PHASE    RESTARTS  ISSUES
temporal-frontend-cfc997fcf-ckd4j       temporal    Running  94        temporal-frontend: 94 restart(s)
harbor-jobservice-5fcd494567-p2bmq      harbor      Running  141       jobservice: 141 restart(s)

# Get full context on the worst offender
$ k0 pod temporal/temporal-frontend-cfc997fcf-ckd4j

POD  temporal-frontend-cfc997fcf-ckd4j
  Namespace  temporal    Node  hunter-hp-elitedesk-800-g4-dm-35w-taa
  Phase      Running     Age   39d

ISSUES
  › temporal-frontend: 94 restart(s)

CONTAINERS
  [temporal-frontend]  Running  ready  94 restarts
    Image  docker.io/temporalio/server:1.30.2
    Last   Terminated(1)
...

Agent Usage

Run k0 commands directly and analyze the output. Start broad, then drill down:

# 1. Get the lay of the land
k0 dashboard
k0 pods

# 2. Drill into any problem pod
k0 pod <namespace>/<name>

k0 pod returns everything needed to diagnose in a single call — no need to run separate kubectl commands for events, logs, ownership, or services. Use --output json if you need to parse specific fields programmatically.