Your pod entered a CrashLoopBackOff state immediately after it was deployed. What are your structured steps to identify the root cause of the problem and resolve it?
I start executing kubectl describe pod to check the Events section and see the exit code and final error message. Then I read the logs of the previous container that crashed via kubectl logs <pod> --previous. If the crash was caused by a lack of settings or secrets, I review the ConfigMaps/Secrets, and finally I check for OOMKilled memory constraints or a failed livenessProbe check.
Detailed Technical Explanation & PracticeExpand DetailsCollapse Details
Fast and professional diagnostic methodology:
- Checking the events and status of the container:
Search the output of thekubectl describe pod <pod-name> -n <ns>State: Waitingsection and theLast State: Terminatedsection:Exit Code 137: Container killed due to out of memory (OOMKilled: true).Exit Code 1or2: A programming error in the application code or the configuration file was not found.Exit Code 0: The container code terminated successfully because it does not have a permanent background process (ie a script that has finished executing and is closed).
- Reading the history of the previous finished container:
kubectl logs <pod-name> -c <container-name> -p -n <ns> - Check the settings of the health sensors (Probes):
If an application takes a long time to boot (such as Java Spring Boot),
livenessProbemay kill it before initialization is complete. Solution AddingstartupProbewithfailureThresholdis sufficient.
- Using kubectl logs without the -p/--previous flag, displays logs for the new container that may be empty or not started yet, while the real error is logged in the previous container that crashed.
- The constant assumption is that CrashLoopBackOff is a code issue, when it is often due to the absence of a mandatory environment variable (Missing Env Var) or a failed connection to an unavailable database.
- What is the difference between Exit Code 0, Exit Code 1, Exit Code 137, and Exit Code 143 in inspecting collapsed containers?
- How can I use the kubectl debug command to open an Ephemeral Container within the same Pod?
A Pod has remained Pending for ten minutes. What is your step-by-step diagnostic workflow?
Start with the Pod events, then verify scheduler constraints and cluster capacity. Run kubectl describe pod to identify the scheduling reason; check requests, node selectors, affinity, taints, quotas, PVC binding, and available node resources before changing the workload.
Detailed Technical Explanation & PracticeExpand DetailsCollapse Details
Use a repeatable order so you do not guess:
kubectl describe pod <pod> -n <namespace>
kubectl get events -n <namespace> --sort-by='.lastTimestamp'
kubectl get nodes
kubectl top nodes
kubectl get pvc -n <namespace>Look for FailedScheduling events first. Common causes are insufficient requested CPU or memory, a node selector that matches no node, a taint without a matching toleration, an unsatisfied affinity rule, a namespace quota, or a PVC that is still Pending.
- Deleting and recreating the Pod before reading its Events; this can hide the useful scheduling message.
- Increasing cluster size before checking a mismatched node selector, an unbound PVC, a quota, or an untolerated taint.
- Which scheduler event indicates that a PersistentVolumeClaim is blocking scheduling?
- How do requests differ from limits when the scheduler decides placement?
A new working capsule is stuck in Pending state and won't start working. What are the possible causes and how do you confirm the cause?
Pending condition means that Kube-Scheduler was unable to find a qualified node that meets the pod's requirements. The reason is immediately confirmed by running kubectl describe pod and looking in the Events section. The most common reasons are: insufficient processor or memory resources (0/N nodes available: Insufficient cpu/memory), NodeAffinity restrictions, Taints without Tolerations, or Waiting to mount a storage disk (VolumeBinding).
Detailed Technical Explanation & PracticeExpand DetailsCollapse Details
Table of Pending status causes and resolution procedures:
The event message in kubectl describe pod |
Technical meaning | Practical solution |
|---|---|---|
0/6 nodes available: Insufficient cpu |
The sum of requests.cpu of pods exceeds the capacity of current nodes |
Reduce requests, or activate Cluster Autoscaler to add new servers |
0/6 nodes available: 3 node(s) had untolerated taint |
The nodes have Taint tags and the pod does not have toleration | Add tolerations to match or remove unintended taint from the |
pod has unbound immediate PersistentVolumeClaims |
The PVC is unable to find or reserve a matching PV disk | Check the StorageClass and match the disk capacity and the required AccessMode |
0/6 nodes available: 6 node(s) didn't match PodTopologySpread |
Geographic distribution restrictions prevent additional capsules from being placed in this area Review topologySpreadConstraints and modify maxSkew |
- Attempt to restart or delete the pod in hopes of resolving the issue; the pod will return to the Pending state immediately because the resource or node restrictions have not changed.
- Confusion between requests and actual resource consumption limits; scheduling is based solely on requests.
- How to address the issue of 0/5 nodes available: Insufficient memory in a cloud environment that supports Cluster Autoscaler?
- How does having an RWO disk associated with a specific Zone affect limiting Pod scheduling to that Zone only?