A pod dies. The reflex is kubectl delete pod or a bump to limits.memory. Ten minutes later it dies again — same place, same silence. Restarting is not a fix; it is a coin flip that hides the cause. What actually works is reading the four artifacts Kubernetes already left you: events, the previous container's logs, describe, and metrics. The prompts below make an LLM walk the layers — image, config, resources, network, permissions — in order, instead of guessing.
Why "restart and wait" keeps failing
A crash is a symptom. CrashLoopBackOff is not one bug — it is the kubelet saying "the container exited and I am backing off." The backoff doubles (10s, 20s, 40s…) and buries the real event under retries. If you delete the pod, you destroy the only witness. More on the topic: “From CrashLoopBackOff to a Working Helm Chart: 12 Prompts That Turn an LLM Into Your Kubernetes Sidekick”.
The same myth in another costume: "add resources." An OOMKilled from a memory limit and a OOMKilled from a node under pressure are different problems. Raising the limit fixes one and delays the other.
kubectl describe pod and kubectl logs --previous. The previous container's logs are gone the moment a new container starts.
Prompt 1: Read the crash before you touch it
For any CrashLoopBackOff. It forces a layer-by-layer read instead of a fix.
Prompt:
You are an SRE. I will paste kubectl describe output, events, and previous logs for a pod in CrashLoopBackOff. Do not suggest a fix yet. First: (1) state the exact exit code and reason (Error, OOMKilled, Completed, etc.) and what each means; (2) list the last 5 events with timestamps and flag the first event that is not a retry; (3) from the previous logs, quote the last 15 lines before exit; (4) name which layer is implicated: image, config, resources, network, or permissions. Output a table with layer, evidence, confidence (high/medium/low).
Which layer to check for each crash symptom
| Symptom | Most likely layer | First thing to read |
|---|---|---|
| CrashLoopBackOff, exit 1 | Config / network | Previous container logs |
| OOMKilled | Resources | Memory curve vs limit |
| ImagePullBackOff | Image / secrets | imagePullSecrets + secret type |
| Never Ready | Probes | initialDelay vs warm-up |
| Starts, can't reach service | Network / DNS | NetworkPolicy + targetPort |
Example input: exit code 1, event Back-off restarting failed container, logs ending in Error: connect ECONNREFUSED 10.96.0.14:5432. The model should point at network/config, not at the image.
Prompt 2: Separate OOMKilled from a limit that is just too low
For pods dying with OOMKilled. It distinguishes a leak from a badly sized limit.
Prompt:
Here are 24h of container_memory_working_set_bytes for this pod (or a description if you only have kubectl top). Tell me: is memory rising steadily (leak), sawtoothing (GC pressure), or flat then spiking (traffic burst)? Compare the observed peak to spec.containers[].resources.limits.memory and requests. Recommend one of: raise limit, lower limit + fix leak, add a horizontal autoscaler. Justify with the shape of the curve, not with a number alone.
A steady climb that peaks right at the limit is a leak. A flat line that jumps once at 03:00 is a batch job — raising the limit just moves the wall.
Prompt 3: ImagePullBackOff is a secrets problem more often than a registry problem
For ImagePullBackOff / ErrImagePull. The model checks the boring causes first.
Prompt:
The pod shows ErrImagePull. Walk me through, in order: (1) is the image tag/digest real and pullable (typo, missing tag defaults to :latest); (2) does the imagePullSecret exist in the same namespace and is it referenced in the pod spec; (3) is the secret of type kubernetes.io/dockerconfigjson and not empty; (4) does the node have egress to the registry. For each, give the exact kubectl command to verify.
Most of these are a secret in the wrong namespace or a missing imagePullSecrets entry — not a broken registry.
Prompt 4: When readiness probes kill a healthy app
For pods that restart or never become Ready. Probes are a config layer, not a resource layer.
Prompt:
Here is my deployment's readinessProbe and livenessProbe. The app takes ~40s to warm up. Identify: initialDelaySeconds vs actual warm-up, timeoutSeconds vs p99 latency, and whether liveness is checking a dependency (DB, cache) that should not kill the pod. Propose corrected values and explain what each change prevents.
A liveness probe pointed at a downstream DB is a self-inflicted outage: the DB blips, every pod restarts, the DB gets hammered harder.
Prompt 5: Network policy and DNS — the silent killers
For pods that start fine but cannot reach a service. The model reasons about policy and DNS, not app code.
Prompt:
My pod can start but cannot reach service X on port Y. Given my NetworkPolicy manifests and the service/DNS name, tell me: (1) is egress allowed from this pod's labels to X's labels on Y; (2) does the DNS name resolve to the service ClusterIP; (3) is the target port matching the container port. Give kubectl/exec commands to test each layer in isolation (nslookup, curl to ClusterIP, curl to pod IP).
A common trap: the policy allows the port but the service's targetPort points at a port the container never opened.
Prompt 6: The Dockerfile audit — before it becomes a crash
For images that are heavy, slow to pull, or fail on a missing dependency. This is the config/image layer, caught early.
Prompt:
Review this Dockerfile. Flag: (1) layers that bloat the image (no multi-stage build, apt cache not cleaned); (2) a base image that is not pinned; (3) missing non-root user; (4) dependencies copied without a lockfile. For each, give the rewritten line.
An unpinned base image is a future ImagePullBackOff or a silent behavior change on redeploy.
Prompt 7: Plan the rollback before you need it
For when a deploy is the suspected cause. It turns panic into a checklist.
Prompt:
My deployment started crashing after a rollout. Give me a safe rollback plan: check rollout history, verify the previous ReplicaSet is healthy, run kubectl rollout undo with a revision, and confirm readiness before declaring success. Include what to capture first (logs, events) so the bug is not lost after rollback.
Rollback restores service; it does not explain the crash. Capture evidence first.
The habit that replaces the reflex
Next time a pod dies, the sequence is: capture events and previous logs, then run the matching prompt above, then change one thing. The restart button is not a diagnosis — it is a bet. The prompts just make the bet unnecessary.
If you want the broader workflow — from docker run to a managed cluster and what actually breaks in production — start with the fundamentals and build the reflex in the right order.