Debug the failing workload
Read the evidence around a failed Pod and isolate whether it could schedule, start, or keep running.
What you will understand
- Distinguish scheduling failures, image pull failures, and repeated crashes.
- Gather current and previous logs, events, and object status before making a change.
- Use an ephemeral debug container when the application image lacks diagnostic tools.
Builds on: Protecting Secrets and tenant boundaries
What each Pod failure status tells you
A deployment dashboard shows an unavailable API. One Pod says Pending, another says ImagePullBackOff, and a third says CrashLoopBackOff. Those words tell you where to begin. Pending is a Pod phase and can cover several stages before containers are ready. If the Pod has no node, Events can explain which requests or constraints prevented scheduling. If it has a node, look at container state and volume events to see what setup is waiting for.
ImagePullBackOff means a pull failed and the kubelet is delaying further attempts. Look for an earlier event with the image name and the actual error, such as a missing tag or denied access. CrashLoopBackOff means a container keeps terminating and Kubernetes is spacing out restarts. Previous logs, the last exit state, and probe events can show whether it crashed, was killed for memory, or was restarted after failed health checks. Try each category in the failure scene.
What can you learn from each failing Pod?
A scheduling failure, a failed image pull, and a repeatedly exiting process produce different evidence and need different fixes.
No node assignment
- Pod objectSchedulernot yet assigned
- SchedulerEvidenceFailedScheduling
An unassigned Pod with FailedScheduling needs scheduler evidence, not application logs from a process that never ran.
Node assigned, image unavailable
- SchedulerImage retrievalassigned node
- Image retrievalEvidencepull event
After node assignment, a pull error can produce ImagePullBackOff. Read the exact registry or network failure in events.
Process ran and exited
- Image retrievalApp processcontainer starts
- App processEvidencelast termination
A retrieved image can start and then exit. Restart backoff produces CrashLoopBackOff as a container waiting reason.
Choose the next useful check
- EvidencePod objecttargeted correction
Previous logs explain a terminated process when available, while events explain placement and setup. Change only a demonstrated cause.
One application container; displayed waiting reasons are not separate Pod phases.
Inspect YAML or commands
Choose evidence by boundary
kubectl logs FAILING_POD -c app --previous --tail=100Explore another case
Collect startup evidence before changing the workload
Use your actual namespace and Pod name in the commands, and replace app with the container you want to inspect. Start with owner objects and Pod placement. In the Pod YAML, check status.containerStatuses, including the current and last state, restart count, and readiness. --previous asks for logs from the preceding terminated instance of that container. If it never started, there may be no logs to retrieve. Record the exact error before changing fields or deleting the Pod.
kubectl get deployment,replicaset,pod -n learning -o wide
kubectl describe pod FAILING_POD -n learning
kubectl get events -n learning --sort-by=.metadata.creationTimestamp
kubectl logs FAILING_POD -n learning -c app --tail=100
kubectl logs FAILING_POD -n learning -c app --previous --tail=100
kubectl get pod FAILING_POD -n learning -o yamlDebug a container that lacks a shell
When a running Pod uses a minimal image, kubectl exec can fail because there is no shell or diagnostic tool inside it. An ephemeral debug container is an extra container you can add for troubleshooting. It can use the Pod network and, with a supporting runtime, target another container’s process namespace. It has its own image and filesystem. Adding it requires the relevant permissions and must pass admission.
# Use a throwaway Pod and an approved debug image in the local lab.
kubectl debug -it FAILING_POD -n learning \
--image=busybox:1.36 --target=app
# From the debug shell, inspect connectivity without printing credentials.
# An exit returns to your local shell; it does not delete the application Pod.Add tools to diagnose an existing Pod
An ephemeral container can inspect the running Pod’s network. It uses its own image and needs the appropriate API permission.
Identify the network question
- OperatorAPI subresourceadd debug container
The application has no shell, but the operator needs to test the listener from its network namespace.
Check policy and permissions
- API subresourceApp Podpermitted update
The subresource request must pass authorization and admission. Debugging does not automatically grant host access.
Add the ephemeral container
- API subresourceDebug containerdebug image
- Debug containerPod networkshared network
The ephemeral container joins the Pod network and may target process visibility when supported by the runtime.
Observe from the existing Pod
- Debug containerApp Poddiagnose listener
Test the relevant localhost port or namespace evidence. The debug container does not replace the application or become its deployment revision.
Runtime supports the requested target visibility; privileges and process namespace access are not universal.
Inspect YAML or commands
Start tools beside the app
kubectl debug -it FAILING_POD --image=busybox:1.36 --target=appExplore another case
Use an approved image in a disposable Pod. Test a hostname and port from within that Pod’s network, then exit. The application Pod continues on its own and the ephemeral container is part of that Pod’s record for the rest of its lifetime. Try the workload debugging lab to repair an intentional failure and confirm recovery.
Capture evidence while it is available
Events can expire and --previous is limited to the previous instance, so save useful evidence before restarting anything. Many workloads restart continuously after a configuration error. Resolve the first concrete error and rerun the same health check before making more changes.
Check your understanding
A Pod is assigned to a node. The application container has never started, and Events show a denied image pull. Where should you investigate first?
Verify the image path and whether the kubelet has authorized pull credentials for that registry in this namespace. There is no process output to inspect until the image can be pulled and the container starts.
Primary documentation
Go to the source
Reviewed 2026-10-27 · Kubernetes 1.37 · Related local exercise