Interview Prep/Kubernetes/Pod startup failures

`kubectl logs web-0 --previous` returns nothing useful and the container dies in under a second. How do you get inside it?

IntermediateTroubleshootingPod startup failures
Answer

Likely causes → The process exits before it writes logs (bad entrypoint, missing binary, crash in a wrapper script), so there is nothing to read.

Diagnose →

# Copy the Pod, override the command so it stays alive
kubectl debug web-0 -it --copy-to=web-0-debug --container=app -- sh
# Or attach an ephemeral debug container sharing the process namespace
kubectl debug -it web-0 --image=busybox:1.36 --target=app
# Check what the image would run
crane config registry.example.com/web:1.4 | jq '.config.Entrypoint, .config.Cmd'

Fix → Inside the copy, run the real entrypoint by hand and read the error. Typical findings: wrong path, missing shared library, script with CRLF line endings.

Prevent → Run the image locally in CI (docker run --rm image --version) as a smoke test before pushing.

All Kubernetes questions Roadmap: Kubernetes core

More on Pod startup failures