agentleFS
polytheseuspolytheseus/sre-skills/skills/k8s-debug/SKILL.md

k8s-debug

Skill0 starsChanged 14 days agoMITView on GitHub

Systematically debug Kubernetes workloads — pods stuck Pending, CrashLoopBackOff, OOMKilled, ImagePullBackOff, failing readiness probes, Services with no endpoints, DNS and network problems. Use when the user mentions kubectl, pods, deployments, a cluster, or a workload that won't start or serve traffic.

  • Reads credentials

4 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions4 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 4

    1. ArangoGutierrez/claude-toolkit★ 4same name
    2. Thakurvaibhav/platform-agent-harness★ 2same name
    3. uprinter/ai-agents-team★ 1same name
    4. vhata/claude-skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository5 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 2 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use read-only commands (get, describe, logs, top, events, auth can-i) freely.

    line 13
  2. Very specific:

    Always pass -n <ns> explicitly instead of relying on the default namespace.

    line 23
  3. Very specific:

    If READY is lower than desired, take one failing pod and go to step 2.

    line 34
  4. Distinctive:

    If the rollout is stuck, compare the new and old ReplicaSets: the new one is usually failing for one of the reasons below.

    line 35
  5. Very specific:

    Run kubectl describe pod/<pod> -n <ns> and read Events at the bottom, plus State / Last State / Reason / Exit Code per container.

    line 40
  6. Very specific:

    Don't print secrets: If you need to verify that a secret is present, check the key names and sizes (kubectl describe secret <s> -n <ns>), …

    line 75
  7. Distinctive:

    When several pods on the same node fail, or the cause is eviction:

    line 80

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Kubernetes debugging

Work from the outside in: workload → pod → container → node → network. At each layer, read the status and events before forming a theory.

Ground rules

  • Use read-only commands (get, describe, logs, top, events, auth can-i) freely. Before anything that changes the cluster (delete, rollout restart, scale, edit, apply, cordon/drain), show the command and its effect, and get the user's go-ahead.
  • Confirm the context and namespace first. Debugging the wrong cluster is a classic way to lose an hour or to break something else:
    kubectl config current-context
    kubectl get ns
  • Always pass -n <ns> explicitly instead of relying on the default namespace.

1. Workload overview

kubectl get deploy,sts,ds,rs,pods -n <ns> -o wide
kubectl describe deploy/<name> -n <ns>      # conditions, replica counts, events
kubectl rollout status deploy/<name> -n <ns> --timeout=10s
kubectl get events -n <ns> --sort-by=.lastTimestamp | tail -30

If READY is lower than desired, take one failing pod and go to step 2. If the rollout is stuck, compare the new and old ReplicaSets: the new one is usually failing for one of the reasons below.

2. Pod status → cause

Run kubectl describe pod/<pod> -n <ns> and read Events at the bottom, plus State / Last State / Reason / Exit Code per container.

SymptomLikely causesCheck
PendingInsufficient CPU/memory, unsatisfiable nodeSelector/affinity/taints, unbound PVC, ResourceQuotaEvents (FailedScheduling text says which), kubectl describe nodes | grep -A5 Allocated, kubectl get pvc -n <ns>, kubectl describe quota -n <ns>
ImagePullBackOff / ErrImagePullTypo in image/tag, tag doesn't exist, private registry without imagePullSecrets, registry rate limitEvent message; kubectl get pod <pod> -o jsonpath='{.spec.containers[*].image}'; check the secret exists in this namespace
CrashLoopBackOffApp exits on start: bad config/env, missing secret, can't reach dependency, wrong command, failing migrationkubectl logs <pod> -c <c> --previous (the crashed instance, not the new one), exit code below
OOMKilled (exit 137)Memory limit too low, or a leakkubectl top pod, limit vs actual; JVM/Node heap flags vs container limit
CreateContainerConfigErrorReferenced ConfigMap/Secret or key missingEvent names the missing object
Running but not ReadyReadiness probe failing: wrong path/port, app slow to start, dependency downEvents (Unhealthy), probe spec, curl the probe from inside the pod
Terminating foreverFinalizers, stuck volume detach, node gonekubectl get pod -o jsonpath='{.metadata.finalizers}', node status
Restarting with no OOMLiveness probe killing a slow or busy appEvents show Liveness probe failed; consider a startupProbe or a looser threshold

Exit codes: 0 the process finished (wrong command for a long-running container?), 1 app error (read the logs), 126/127 command not executable / not found, 137 SIGKILL (OOM or liveness), 139 segfault, 143 SIGTERM (normal on shutdown, suspicious otherwise).

3. Inside the container

kubectl logs <pod> -n <ns> -c <container> --since=15m
kubectl logs <pod> -n <ns> -c <container> --previous
kubectl get pod <pod> -n <ns> -o jsonpath='{.spec.containers[*].env[*].name}'   # env var names only, no values
kubectl exec -n <ns> <pod> -c <container> -- sh -c 'wget -qO- localhost:<port>/<probe-path>'

For distroless images without a shell, use an ephemeral debug container (this modifies the pod spec, so ask first):

kubectl debug -n <ns> <pod> -it --image=busybox:1.36 --target=<container>

Don't print secrets. If you need to verify that a secret is present, check the key names and sizes (kubectl describe secret <s> -n <ns>), not the values.

4. Node layer

When several pods on the same node fail, or the cause is eviction:

kubectl get nodes -o wide
kubectl describe node <node>     # Conditions: MemoryPressure, DiskPressure, PIDPressure, Ready
kubectl top nodes
kubectl get pods -A --field-selector spec.nodeName=<node>

Evicted pods mean node pressure, so check the node's conditions. A NotReady node usually means kubelet or runtime trouble, or the node is gone. That is a cloud/infra question.

5. Service and network

A pod is Ready but traffic doesn't reach it:

kubectl get svc <svc> -n <ns> -o wide
kubectl get endpointslices -n <ns> -l kubernetes.io/service-name=<svc>
  • No endpoints → the Service selector doesn't match the pod labels, or no pods are Ready. Compare kubectl get svc <svc> -o jsonpath='{.spec.selector}' with kubectl get pods --show-labels.
  • targetPort mismatch → the Service points at a port the container isn't listening on.
  • DNS → from a debug pod: nslookup <svc>.<ns>.svc.cluster.local; check that CoreDNS pods are healthy in kube-system.
  • NetworkPolicy → kubectl get networkpolicy -n <ns>. A default-deny policy plus a missing allow rule shows up as silent timeouts.
  • Ingress → kubectl describe ingress <ing> -n <ns>, check the backend service/port names, then the ingress controller's logs.

6. Report

Finish with:

  • Cause — the specific failing layer and evidence (quote the event/log line)
  • Fix — the exact manifest change or command, as a diff where possible
  • Verify — the command that will show it worked
  • Prevent — e.g. resource requests/limits, probe tuning, a CI check that validates image tags or Secret references before deploy

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.