Kubernetes Troubleshooting Cheatsheet: Essential Commands and Real-World Scenarios

Listen to this Post

Featured Image
Kubernetes is a powerful container orchestration platform, but troubleshooting issues can be complex. This cheatsheet covers essential commands and techniques to diagnose and resolve common Kubernetes problems efficiently.

You Should Know:

1. Check Cluster Status

kubectl cluster-info 
kubectl get nodes 
kubectl describe node <node-name> 

– Verify if nodes are Ready.
– Check for MemoryPressure, DiskPressure, or PIDPressure.

2. Pod Debugging

kubectl get pods --all-namespaces 
kubectl describe pod <pod-name> -n <namespace> 
kubectl logs <pod-name> -n <namespace> 
kubectl logs --previous <pod-name> -n <namespace>  For crashed pods 

– Look for CrashLoopBackOff, ImagePullBackOff, or `Pending` statuses.

3. Networking Issues

kubectl get svc -n <namespace> 
kubectl describe svc <service-name> -n <namespace> 
kubectl get endpoints <service-name> -n <namespace> 

– Ensure `Endpoints` are correctly assigned.
– Check `kube-proxy` and `CNI` plugin logs.

4. Resource Constraints

kubectl top pods -n <namespace> 
kubectl top nodes 
kubectl get events --sort-by='.metadata.creationTimestamp' 

– Identify OOM (Out of Memory) kills.
– Adjust `requests` and `limits` in deployments.

5. Persistent Volume (PV) Issues

kubectl get pv 
kubectl get pvc -n <namespace> 
kubectl describe pvc <pvc-name> -n <namespace> 

– Check StorageClass, AccessModes, and binding status.

6. RBAC & Permissions

kubectl auth can-i <verb> <resource> --as=<service-account> -n <namespace> 
kubectl get roles,rolebindings -n <namespace> 

– Verify if service accounts have required permissions.

7. API & Control Plane Debugging

kubectl get --raw='/readyz?verbose' 
kubectl get --raw='/healthz?verbose' 
journalctl -u kubelet -f  Check kubelet logs 

– Ensure kube-apiserver, etcd, and `kube-scheduler` are healthy.

8. Helm & Custom Resource Issues

helm ls -n <namespace> 
helm status <release-name> -n <namespace> 
kubectl get crd 

– Check for failed Helm releases or missing CRDs.

What Undercode Say:

Kubernetes troubleshooting requires a structured approach. Always start with `kubectl get` and `describe` commands before diving into logs. Automate checks with scripts and integrate monitoring tools like Prometheus and Grafana.

Prediction:

As Kubernetes adoption grows, AI-driven troubleshooting tools will emerge, reducing manual debugging efforts.

Expected Output:

A well-documented Kubernetes troubleshooting workflow with actionable commands.

Relevant URL:

TechOps Examples Newsletter

IT/Security Reporter URL:

Reported By: Govardhana Miriyala – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 Telegram