Pod startup and crash diagnosis
Start with the failure stage
A Pod that cannot start is not necessarily an application crash. First confirm the approved cluster and namespace, workload name, Pod UID and affected container. Then compare the requested specification with observed conditions, container states and recent events. Pending is a Pod phase; ContainerCreating, ErrImagePull, ImagePullBackOff and CrashLoopBackOff can appear as client status or container waiting reasons instead. A Running phase does not guarantee readiness. Record a timestamp and avoid collecting Secret values. The commands below are static examples for an explicitly authorized disposable cluster; the named objects are fictional.
kubectl --kubeconfig ./lab.kubeconfig --context bm-lab -n bm-troubleshoot get pod catalog-abc -o widekubectl --kubeconfig ./lab.kubeconfig --context bm-lab -n bm-troubleshoot describe pod catalog-abcSeparate placement from container setup
If PodScheduled is False and the event reports insufficient CPU, examine requests versus eligible-node allocatable capacity and already allocated requests. Lowering a request without evidence may cause overload; choose a verified capacity or placement change. If PodScheduled is True but a container is waiting with FailedMount, examine the referenced volume and claim. A missing ConfigMap or Secret key can also stop setup before any application logs exist. ErrImagePull records a failed pull; ImagePullBackOff means a retry delay is active. Verify the intended digest, registry availability and authorized pull credentials without printing them.
Synthetic observation A: PodScheduled=False; FailedScheduling: Insufficient cpuSynthetic observation B: PodScheduled=True; FailedMount: config volume unavailableSynthetic observation C: waiting.reason=ImagePullBackOff; event: manifest unknownRead the previous container failure
For a restart loop inspect both current and last termination state, exit code, restart count and timestamps. Use previous logs for the prior terminated instance of the selected container if retained; absence of logs is not proof it never ran. A nonzero exit can reflect bad arguments or application bugs; exit code 137 alone does not prove an out-of-memory kill. OOMKilled is stronger evidence for a memory-related termination; review usage, limit and workload behavior before tuning. Failed startup or liveness probes can cause restarts; failed readiness alone normally removes a Pod from ready traffic rather than restarting it. Inspect initContainerStatuses when the main container never starts.
kubectl --kubeconfig ./lab.kubeconfig --context bm-lab -n bm-troubleshoot logs catalog-abc -c catalog --previous --tail=80kubectl --kubeconfig ./lab.kubeconfig --context bm-lab -n bm-troubleshoot get pod catalog-abc -o jsonChoose the least intrusive test
Read-only inspection comes before interactive debugging. If a running container has a suitable tool and permission is granted, exec can run a narrowly scoped diagnostic command. Minimal images may have no shell. Adding an ephemeral debug container changes the Pod, needs authorization and admission acceptance, and cannot be undone by removing that container from the Pod spec. Use only a reviewed debug image in an approved isolated lab; do not grant elevated privileges to make diagnostics easier. In the offline exercise classify the failure stage and propose one evidence-gathering action, not a blanket restart.
Evidence: previous log says invalid catalog mode; last exit=2Hypothesis: configuration is invalidNext: compare intended non-secret mode against application contractVerify: corrected configuration, stable restart count and successful requestCheck Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Pod startup and crash diagnosis — knowledge check
Distinguish image pull, pending and crash loop causes
PodScheduled=False with FailedScheduling: Insufficient cpu. What should you check first?
What does ImagePullBackOff indicate?
Which command requests logs for the prior terminated catalog container?
Exit code 137 alone proves which fact?
Which failed probe alone normally removes readiness without restarting?