
Kubernetes Course 10 — The First 'Didn't Come Up': Diagnosing Pods
This is the chapter you'll reread. Kubernetes doesn't hide the problem: it gives you states, events, and logs. The hard part is knowing what order to look.
Course seal: commands valid for Kubernetes 1.35. Replace names/namespaces with your own.
The method in 6 steps
- What's happening?
kubectl get pods -o wide - Why?
kubectl describe pod <pod>(look at Events at the end) - Did the app complain?
kubectl logs <pod>and--previous - Is the node healthy?
kubectl describe node <node>,kubectl top - Is network/config correct? endpoints, DNS, secrets, probes
- Do I need to get into the pod?
kubectl execorkubectl debug
The state tells the story
| Status | First question | Command |
|---|---|---|
Pending |
did the scheduler manage to schedule? | describe pod → Events |
ContainerCreating |
image/volume/CNI? | describe pod |
ImagePullBackOff |
does the image exist/have access? | Events + imagePullSecrets |
CrashLoopBackOff |
why does the process die? | logs --previous |
OOMKilled |
did it run out of memory? | describe → Last State |
RunContainerError |
entrypoint/permission? | logs, describe |
Terminating |
finalizer/PDB/node? | describe, get pdb |
Completed |
Job finished? | normal for Jobs |
Pending
The pod was created, but was not scheduled.
kubectl describe pod <pod> | tail -30
Common causes:
- Insufficient resources (
Insufficient cpu/memory). - Impossible
nodeSelector/affinity. - Taint on node without toleration.
- Unbound PVC (
pod has unbound immediate PersistentVolumeClaims). - Namespace quota exceeded.
- Required anti-affinity without available node.
Real case: during maintenance of a worker, Elasticsearch and RabbitMQ pods became
Pendingbecause the anti-affinity required one node per replica and there were only two schedulable nodes. It wasn't lack of resources; it was distribution rule.
ContainerCreating and ImagePullBackOff
kubectl describe pod <pod> | grep -A6 Events
- Nonexistent image/wrong tag: registry responds 404.
- Private registry: missing
imagePullSecret. - Rate limit: Docker Hub without authentication.
- Wrong architecture:
amd64image onarm64node. - Image only cached on some nodes: if the pod is rescheduled, it fails.
Real case: an image was cached on two nodes and not on the third. When the pod was rescheduled, it went into
ErrImagePull. It "worked" until the node changed.
CrashLoopBackOff
The container starts and dies. The current log may be empty; use the previous one:
kubectl logs <pod> --previous
kubectl describe pod <pod> | grep -A5 'Last State'
Causes:
- Missing environment variable/secret.
- Unavailable dependency (database, queue, DNS).
- File/volume permission.
OOMKilled(memory limit).- Liveness killing the app before finishing boot.
Real case: the app started, Flyway applied the migration and the credential guard killed the process. The current log showed only the beginning;
--previousshowed the exception.
OOMKilled
kubectl describe pod <pod> | grep -i oom
kubectl top pod <pod>
Symptoms: Last State: Terminated, Reason: OOMKilled. Increase the limit based on real usage, not guesswork. JVM/Node memory needs margin for off-heap.
Misconfigured probes
- Failing
readinessProbe: podRunningbut0/1, out of Service. - Aggressive
livenessProbe: loop restart during boot. - Missing
startupProbein slow app: liveness kills before it comes up.
kubectl describe pod <pod> | grep -A4 -i probe
Network and DNS
kubectl -n <ns> get endpoints <service>
kubectl -n <ns> run dns --image=busybox:1.36 --rm -it --restart=Never -- nslookup <service>
If DNS fails, check CoreDNS and NetworkPolicy. If the Service has no endpoints, the selector is wrong or the pod is not Ready.
Enter the pod
kubectl exec -it <pod> -- sh
kubectl debug -it <pod> --image=busybox:1.36 --target=<container>
kubectl debug is useful when the image has no shell. For nodes, kubectl debug node/<node> creates a privileged pod — use with care.
Cluster events
kubectl get events -A --sort-by=.lastTimestamp | tail -30
kubectl -n <ns> get events --sort-by=.lastTimestamp
Events expire (1h by default). If the problem was yesterday, you need logs/monitoring, not get events.
Permission and admission errors
forbidden: ServiceAccount RBAC.admission webhook denied: policy/PSA.failed quota: ResourceQuota.LimitRange: request/limit out of allowed range.
kubectl auth can-i list pods --as=system:serviceaccount:<ns>:<sa>
Diagnostic checklist
- [ ]
get pods -o wide(node, IP, restarts). - [ ]
describe podwith Events. - [ ]
logsandlogs --previous. - [ ]
describe nodeandtop. - [ ] endpoints/DNS.
- [ ] secrets/configmaps/probes.
- [ ] namespace events.
- [ ] RBAC/admission.
Glossary
- Event: ephemeral record of cluster decision.
- BackOff: exponential wait before new attempt.
- OOMKilled: death by memory limit.
- Ephemeral container: diagnostic container attached to the pod.
- Admission webhook: validation/mutation at API entry.
Next
Season 1 completed. In Season 2 we will deep dive into storage, configuration, operators and backup — starting with PV, PVC, NFS and local-path.
Next: Kubernetes Course 11 — Storage: PV, PVC, NFS and local-path
Keep reading
Read also
KubernetesKubernetes Course 11 — Storage: PV, PVC, NFS, and local-path
Persistence in Kubernetes without mystery: PV, PVC, StorageClass, access modes, NFS, local-path and what happens when the pod changes nodes.
4 min de leitura
KubernetesKubernetes Course 09 — Services, Ingress, DNS, and TLS
How a pod becomes an accessible service: ClusterIP, NodePort, Ingress, CoreDNS, and certificates with cert-manager — without exposing what shouldn't be.
4 min de leitura
KubernetesKubernetes Course 12 — ConfigMap, Secret, and the Credentials Guard
Configuration without rebuilding the image — and why a Secret with a default value brought down an entire deployment. Best practices, rotation, and alternatives.
4 min de leitura
Comments
No comments yet
Be the first to share your thoughts on this article.
Leave a comment