This systematic workflow helps you diagnose and resolve Kubernetes cluster failures by moving from broad checks to specific fixes. You’ll start with cluster-level health, then drill into workloads, networking, and storage, using kubectl commands at each stage. No prior debugging experience is needed, but basic familiarity with kubectl and YAML is helpful.
What You’ll Need
- Access to the cluster via kubectl (or another client) with permissions to view nodes, pods, events, and logs.
- The kubeconfig file for the cluster you’re troubleshooting.
- Basic understanding of Kubernetes objects: Pods, Deployments, Services, Nodes, and Namespaces.
- Optional: a terminal with jq for parsing JSON output, and a text editor for YAML files.
Step-by-Step
- Check cluster-level health. Run
kubectl get nodesand look forReadystatus. If any node isNotReady, investigate withkubectl describe node <node-name>to see conditions and events. Check kubelet status on the node (e.g.,systemctl status kubeletorjournalctl -u kubelet). - Verify control plane components. If nodes are ready but the API server is unresponsive, check the control plane pods (in kube-system namespace) with
kubectl get pods -n kube-system. Look for CrashLoopBackOff or ImagePullBackOff. Describe the failing pod to see events. - List all namespaces and workloads. Run
kubectl get all --all-namespacesto see the overall state. Identify which workloads are not ready. Usekubectl get pods -n <namespace>to focus. - Inspect pod status. For each pod not in Running/Ready, run
kubectl describe pod <pod-name> -n <namespace>. Look at the Events section at the bottom for clues like FailedScheduling, BackOff, or Unhealthy. - Check pod logs. If the pod is running but crashing, get logs with
kubectl logs <pod-name> -n <namespace> --previous(to see the last crashed attempt). For init containers, usekubectl logs <pod-name> -c <init-container-name>. - Test service connectivity. If pods are running but the service is not reachable, check endpoints with
kubectl get endpoints <service-name> -n <namespace>. If endpoints are empty, check the selector in the service matches the pod labels. Also verify the service type (ClusterIP, NodePort, LoadBalancer) and that the targetPort matches the container port. - Check network policies and DNS. If pods can’t talk to each other, check NetworkPolicies with
kubectl get networkpolicy -n <namespace>. For DNS issues, test withkubectl exec <pod> -- nslookup kubernetes.default. Check CoreDNS pods in kube-system. - Inspect storage issues. If pods are stuck in ContainerCreating, check persistent volume claims with
kubectl get pvc -n <namespace>andkubectl describe pvc <name>. Ensure the PV is bound and the storage class exists. - Review resource limits and quotas. If pods are pending, check if they are requesting more CPU/memory than available. Use
kubectl describe nodeto see allocatable resources. Also check ResourceQuotas in the namespace withkubectl get resourcequota. - Check for taints and tolerations. If pods are unschedulable, see if nodes have taints that the pod doesn’t tolerate:
kubectl describe node | grep -A5 Taints. Add tolerations if needed. - Look at cluster events. Use
kubectl get events --sort-by='.lastTimestamp'to see recent events across the cluster. This often reveals the root cause even if the pod looks fine now. - Check API server and etcd. If the API server is slow or unresponsive, check its logs (if you have access) and etcd health with
kubectl get --raw='/healthz'or etcdctl. Look for disk space issues on control plane nodes. - Verify kube-proxy and CNI. If services are not working, check kube-proxy pods and the CNI plugin (e.g., Calico, Flannel). Look at the CNI daemonset status and logs.
- Apply fixes incrementally. Once you identify the cause, make changes (e.g., fix YAML, delete stuck pods, scale up nodes) and re-check. Use
kubectl rollout restart deployment <name>if needed. - Document and monitor. After resolution, note the cause and fix. Set up monitoring (e.g., Prometheus, Grafana) to catch similar issues early.
Common Mistakes
- Ignoring pod events – Events often contain the exact reason (e.g., FailedScheduling, BackOff). Skipping them wastes time.
- Checking logs without –previous – If a pod is crashing, the current logs may be empty; you need the previous container’s logs.
- Forgetting namespaces – Many commands default to the ‘default’ namespace, but your workload may be elsewhere. Always specify -n.
- Assuming the service selector matches – A typo in labels is a common cause of empty endpoints.
- Overlooking resource limits – A pod might be evicted or stuck if it exceeds memory limits, even if it’s running.
- Not checking node pressure – Disk pressure, memory pressure, or PID pressure on nodes can cause evictions and scheduling failures.
Tips
- Use
kubectl get pods -o wideto see which node each pod runs on, which helps spot node-specific issues. - Set up a kubectl alias like
alias k='kubectl'to speed up typing. - Use
kubectl get all -n <namespace> -o widefor a quick overview with IPs and status. - When a pod is CrashLoopBackOff, check the exit code in the pod description – it often points to the problem (e.g., 137 = OOM killed, 1 = app error).
- For network issues, use a temporary debug pod:
kubectl run -it --rm debug --image=nicolaka/netshoot -- /bin/bash. - Keep a cheat sheet of common kubectl commands and their output meanings.
- If you have access to the cluster’s cloud console, check node health and autoscaling events there.
Troubleshooting
If your initial steps don’t reveal the issue, try these additional approaches:
- Check the kubelet logs on the affected node – You might need SSH access. Look for errors about container runtime, CNI, or image pulls.
- Verify the container runtime – If using containerd or CRI-O, check its status and logs. A misconfigured runtime can cause pods to fail to start.
- Inspect the cluster’s cloud provider integration – If using a managed service (EKS, GKE, AKS), check the provider’s status page and your cloud console for node group issues.
- Check for API rate limiting – If you see 429 errors, you may be hitting API server limits. Reduce the frequency of kubectl calls.
- Use a debugging container – If a pod is stuck in Pending, create a simple pod with the same nodeSelector and see if it schedules. This isolates the issue.
- Review the cluster’s audit logs – If you have access, audit logs can show who or what made changes that broke things.
Frequently Asked Questions
Why is my pod stuck in Pending?
Pending means the scheduler can’t place the pod. Common causes: insufficient CPU/memory, node taints, or a PersistentVolume that can’t be attached. Describe the pod to see scheduler events.
What does CrashLoopBackOff mean?
The container starts, crashes, and Kubernetes restarts it, but it keeps crashing. Check logs with –previous to see the error. Common causes: misconfiguration, missing dependencies, or the app failing on startup.
How do I fix a service that has no endpoints?
Ensure the service selector matches the pod labels. Run kubectl get pods --show-labels to see actual labels, then compare with the service YAML. Also check that the pods are Running and Ready.
Why can’t my pods resolve DNS names?
Check CoreDNS pods in kube-system. If they are running, test with kubectl exec <pod> -- nslookup kubernetes.default. If that fails, check network policies or if the cluster’s DNS config (kubelet’s –cluster-dns) is correct.
What should I do if a node is NotReady?
SSH into the node and check kubelet status and logs. Common fixes: restart kubelet, check disk space, verify the container runtime is healthy, and ensure the node can reach the API server.
How can I prevent cluster failures in the future?
Implement monitoring and alerting (e.g., Prometheus, Grafana), set resource requests/limits, use pod disruption budgets, and regularly test backups and disaster recovery procedures.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Campus Tech Innovation Hubs: What They Are
- Poco C51 Airtel Prepaid Locked Variant India?
- Jenkins vs GitHub Actions: Which CI/CD Fits Your Team?
- Turn Off Backup Encryption in iTunes?
- Shared VPS Hosting: Is It Better?
- Disk Defrag Pro: What It Does and Whether You Need It