Kubernetes Debug
Use this skill when the user is troubleshooting Kubernetes runtime behavior such as failing Pods, broken Service routing, missing endpoints, HTTPRoute or Ingress issues, rollout failures, or namespace-scoped application reachability problems.
This skill is read-only by default. Prefer kubectl get, kubectl describe, kubectl logs, and kubectl events style inspection first.
This skill does not perform write actions. It is limited to read-only troubleshooting.
Never run mutating commands from this skill, including:
kubectl delete
kubectl patch
kubectl scale
kubectl rollout restart
kubectl apply
- changing context or namespace defaults
For interactive troubleshooting commands that may still be useful during investigation, ask for approval step by step before each individual command:
kubectl exec
kubectl debug
kubectl cp
kubectl port-forward
When checking namespaced resources, prefer explicit namespace scoping on every command:
kubectl get pod -n <namespace>
kubectl describe svc -n <namespace> <name>
kubectl logs -n <namespace> <pod>
Do not rely on the current namespace implicitly when debugging user workloads.
Outcomes
- Isolate whether the failure is in the workload, Service wiring, or traffic layer above it
- Explain the concrete broken hop in the request path
- Keep investigation safe by default through read-only inspection
- Leave the user with the exact evidence, command trail, and likely next fix
Where This Fits In The Flow
- Use during intake/triage when the ticket is “something is broken in k8s” and you need a read-only diagnosis.
- Feed the findings back into
infra-kit.workflow artifacts (spec.md/plan.md/tasks.md) before making changes.
Workflow
- Confirm the namespace, workload name, traffic entrypoint, and observed symptom before digging deeper.
- Start at the backend and work outward, bottom to top:
- Pod
- controller (
Deployment, StatefulSet, DaemonSet, Job)
- Service
- EndpointSlice
- HTTPRoute or Ingress
- Gateway or ingress controller exposure when relevant
- Inspect Pods first:
- readiness and liveness failures
- restart counts
- image pull issues
- scheduling failures
- recent logs
- namespace events
- if the Pod is in
Error, CrashLoopBackOff, ImagePullBackOff, or another unhealthy state, capture both describe pod output and error logs into text files for later analysis
- Check the owning controller next for rollout health, replica mismatch, and selector correctness.
- Check the Service:
- selector matches Pod labels
- target port maps to a real container port
- type and annotations fit the intended exposure model
- Check
EndpointSlice objects, not just Service existence. A healthy Service with zero or wrong endpoints is a common break point.
- If Gateway API is used, inspect:
HTTPRoute
- parent refs
- backend refs
- route status conditions
- Gateway listener attachment
- If Ingress is used, inspect:
- rules and path matching
- backend Service and port references
- ingress class
- controller events/status
- Check namespace guardrails that commonly block healthy workloads:
NetworkPolicy for denied east-west or ingress-controller traffic
ResourceQuota for failed scheduling or rejected creates
LimitRange for implicit resource defaults or invalid workload sizing
- Only after the path is mapped should you suggest interactive checks such as
exec or port-forward.
- Do not run those commands automatically. Present the exact next command, explain why it is needed, and wait for explicit user approval before each step.
- If a likely fix requires patching, deleting, restarting, scaling, or applying resources, stop at the diagnosis and tell the user what change is recommended rather than performing it.
Hallucination Guardrails
- Only report health or routing conclusions that are backed by concrete
kubectl output; cite the exact command (and captured file when applicable) so the user can trace every statement to evidence.
- If a resource, namespace, or controller cannot be found, say so explicitly instead of assuming its state; ask the user for corrected names when needed.
- When permissions, kubeconfig access, or tooling limitations block a command, document the blocker and keep the analysis scoped to the data that was actually retrievable.
- Separate read-only evidence from recommended write actions clearly so users understand no mutation occurred and can decide whether to run the fix themselves.
Command Pattern
Prefer a read-only sequence like:
kubectl get pods -n <namespace> -o wide
kubectl describe pod -n <namespace> <pod>
kubectl logs -n <namespace> <pod> --container <container> --tail=200
kubectl get deploy -n <namespace>
kubectl describe deploy -n <namespace> <deploy>
kubectl get svc -n <namespace>
kubectl describe svc -n <namespace> <service>
kubectl get endpointslice -n <namespace>
kubectl describe endpointslice -n <namespace> <slice>
kubectl get networkpolicy -n <namespace>
kubectl describe networkpolicy -n <namespace> <policy>
kubectl get resourcequota -n <namespace>
kubectl describe resourcequota -n <namespace>
kubectl get limitrange -n <namespace>
kubectl describe limitrange -n <namespace>
kubectl get httproute -n <namespace>
kubectl describe httproute -n <namespace> <route>
kubectl get ingress -n <namespace>
kubectl describe ingress -n <namespace> <ingress>
kubectl get events -n <namespace> --sort-by=.lastTimestamp
When the Pod is unhealthy, prefer capturing artifacts as files:
kubectl describe pod -n <namespace> <pod> > describe_pod.txt
kubectl logs -n <namespace> <pod> --container <container> --previous --tail=200 > log_error.txt
If --previous is not applicable, capture the current container logs instead.
If the issue is cross-namespace or controller-level, widen scope deliberately and say why.
Review Priorities
When debugging Kubernetes, check in this order:
- Pod health and recent events
- Controller rollout status and selector consistency
- Service selector and port wiring
- EndpointSlice population and backend IP/port correctness
- NetworkPolicy, ResourceQuota, and LimitRange side effects
- HTTPRoute or Ingress routing rules and status conditions
- Gateway, ingress controller, or external exposure layer
Read-Only Rules
- Default to inspection commands only.
- Never treat
exec, debug, cp, or port-forward as implicitly allowed.
- Ask before entering containers or creating debug containers.
- Ask before port-forwarding, even if it seems harmless.
- Do not perform write, restart, scaling, delete, patch, or apply actions from this skill.
- Make the exact command explicit before requesting approval for each non-read-only step.
- Approval is per step, not blanket approval for a whole debugging session.
Bundled helper:
bash scripts/collect_pod_debug.sh <namespace> <pod> [container]
Delivery Standard
Always leave the user with:
- the exact hop where traffic or workload health breaks
- the commands used to prove it
- the key evidence from Pods, Services, endpoints, routes, and namespace guardrails
- the least invasive recommended fix, clearly separated from read-only findings
1---2name: infra-kit-domain-k8s-doctor3description: Debug Kubernetes workload, networking, routing, and rollout issues using read-only kubectl flows across pods, services, endpoints, HTTPRoute, ingress, and gateway resources.4---56# Kubernetes Debug78Use this skill when the user is troubleshooting Kubernetes runtime behavior such as failing Pods, broken Service routing, missing endpoints, HTTPRoute or Ingress issues, rollout failures, or namespace-scoped application reachability problems.910This skill is read-only by default. Prefer `kubectl get`, `kubectl describe`, `kubectl logs`, and `kubectl events` style inspection first.1112This skill does not perform write actions. It is limited to read-only troubleshooting.1314Never run mutating commands from this skill, including:1516- `kubectl delete`17- `kubectl patch`18- `kubectl scale`19- `kubectl rollout restart`20- `kubectl apply`21- changing context or namespace defaults2223For interactive troubleshooting commands that may still be useful during investigation, ask for approval step by step before each individual command:2425- `kubectl exec`26- `kubectl debug`27- `kubectl cp`28- `kubectl port-forward`2930When checking namespaced resources, prefer explicit namespace scoping on every command:3132```bash33kubectl get pod -n <namespace>34kubectl describe svc -n <namespace> <name>35kubectl logs -n <namespace> <pod>36```3738Do not rely on the current namespace implicitly when debugging user workloads.3940## Outcomes4142- Isolate whether the failure is in the workload, Service wiring, or traffic layer above it43- Explain the concrete broken hop in the request path44- Keep investigation safe by default through read-only inspection45- Leave the user with the exact evidence, command trail, and likely next fix4647## Where This Fits In The Flow4849- Use during intake/triage when the ticket is “something is broken in k8s” and you need a read-only diagnosis.50- Feed the findings back into `infra-kit.workflow` artifacts (`spec.md`/`plan.md`/`tasks.md`) before making changes.5152## Workflow53541. Confirm the namespace, workload name, traffic entrypoint, and observed symptom before digging deeper.552. Start at the backend and work outward, bottom to top:56 - Pod57 - controller (`Deployment`, `StatefulSet`, `DaemonSet`, `Job`)58 - Service59 - EndpointSlice60 - HTTPRoute or Ingress61 - Gateway or ingress controller exposure when relevant623. Inspect Pods first:63 - readiness and liveness failures64 - restart counts65 - image pull issues66 - scheduling failures67 - recent logs68 - namespace events69 - if the Pod is in `Error`, `CrashLoopBackOff`, `ImagePullBackOff`, or another unhealthy state, capture both `describe pod` output and error logs into text files for later analysis704. Check the owning controller next for rollout health, replica mismatch, and selector correctness.715. Check the Service:72 - selector matches Pod labels73 - target port maps to a real container port74 - type and annotations fit the intended exposure model756. Check `EndpointSlice` objects, not just Service existence. A healthy Service with zero or wrong endpoints is a common break point.767. If Gateway API is used, inspect:77 - `HTTPRoute`78 - parent refs79 - backend refs80 - route status conditions81 - Gateway listener attachment828. If Ingress is used, inspect:83 - rules and path matching84 - backend Service and port references85 - ingress class86 - controller events/status879. Check namespace guardrails that commonly block healthy workloads:88 - `NetworkPolicy` for denied east-west or ingress-controller traffic89 - `ResourceQuota` for failed scheduling or rejected creates90 - `LimitRange` for implicit resource defaults or invalid workload sizing9110. Only after the path is mapped should you suggest interactive checks such as `exec` or `port-forward`.9211. Do not run those commands automatically. Present the exact next command, explain why it is needed, and wait for explicit user approval before each step.9312. If a likely fix requires patching, deleting, restarting, scaling, or applying resources, stop at the diagnosis and tell the user what change is recommended rather than performing it.9495## Hallucination Guardrails9697- Only report health or routing conclusions that are backed by concrete `kubectl` output; cite the exact command (and captured file when applicable) so the user can trace every statement to evidence.98- If a resource, namespace, or controller cannot be found, say so explicitly instead of assuming its state; ask the user for corrected names when needed.99- When permissions, kubeconfig access, or tooling limitations block a command, document the blocker and keep the analysis scoped to the data that was actually retrievable.100- Separate read-only evidence from recommended write actions clearly so users understand no mutation occurred and can decide whether to run the fix themselves.101102## Command Pattern103104Prefer a read-only sequence like:105106```bash107kubectl get pods -n <namespace> -o wide108kubectl describe pod -n <namespace> <pod>109kubectl logs -n <namespace> <pod> --container <container> --tail=200110kubectl get deploy -n <namespace>111kubectl describe deploy -n <namespace> <deploy>112kubectl get svc -n <namespace>113kubectl describe svc -n <namespace> <service>114kubectl get endpointslice -n <namespace>115kubectl describe endpointslice -n <namespace> <slice>116kubectl get networkpolicy -n <namespace>117kubectl describe networkpolicy -n <namespace> <policy>118kubectl get resourcequota -n <namespace>119kubectl describe resourcequota -n <namespace>120kubectl get limitrange -n <namespace>121kubectl describe limitrange -n <namespace>122kubectl get httproute -n <namespace>123kubectl describe httproute -n <namespace> <route>124kubectl get ingress -n <namespace>125kubectl describe ingress -n <namespace> <ingress>126kubectl get events -n <namespace> --sort-by=.lastTimestamp127```128129When the Pod is unhealthy, prefer capturing artifacts as files:130131```bash132kubectl describe pod -n <namespace> <pod> > describe_pod.txt133kubectl logs -n <namespace> <pod> --container <container> --previous --tail=200 > log_error.txt134```135136If `--previous` is not applicable, capture the current container logs instead.137138If the issue is cross-namespace or controller-level, widen scope deliberately and say why.139140## Review Priorities141142When debugging Kubernetes, check in this order:1431441. Pod health and recent events1452. Controller rollout status and selector consistency1463. Service selector and port wiring1474. EndpointSlice population and backend IP/port correctness1485. NetworkPolicy, ResourceQuota, and LimitRange side effects1496. HTTPRoute or Ingress routing rules and status conditions1507. Gateway, ingress controller, or external exposure layer151152## Read-Only Rules153154- Default to inspection commands only.155- Never treat `exec`, `debug`, `cp`, or `port-forward` as implicitly allowed.156- Ask before entering containers or creating debug containers.157- Ask before port-forwarding, even if it seems harmless.158- Do not perform write, restart, scaling, delete, patch, or apply actions from this skill.159- Make the exact command explicit before requesting approval for each non-read-only step.160- Approval is per step, not blanket approval for a whole debugging session.161162Bundled helper:163164```bash165bash scripts/collect_pod_debug.sh <namespace> <pod> [container]166```167168## Delivery Standard169170Always leave the user with:171172- the exact hop where traffic or workload health breaks173- the commands used to prove it174- the key evidence from Pods, Services, endpoints, routes, and namespace guardrails175- the least invasive recommended fix, clearly separated from read-only findings