πŸ›  Kubernetes Pod Debugging πŸ› 

πŸ›  Kubernetes Pod Debugging πŸ› 

πŸ” Verify the Obvious

β–Έ kubectl get pods -o wide β†’ Check if the pod is crashed or pending.
β–Έ kubectl describe pod <pod-name> β†’ Inspect restart count, status, and errors.
β–Έ kubectl get events --sort-by='.lastTimestamp' β†’ Look for cluster-wide issues.

πŸ“œ Hunt Through Pod Logs

β–Ή kubectl logs <pod-name> --previous β†’ Logs from the crashed container.
β–Ή kubectl logs <pod-name> -f β†’ Live logs from the current container.
β–Ή kubectl logs <pod-name> -c <container-name> β†’ Debug multi-container pods.

⚑ Check Resource Consumption

β—ˆ kubectl top pods β†’ Identify CPU/Memory spikes.
β—ˆ kubectl describe node <node-name> β†’ Check for node resource pressure.
β—ˆ kubectl get pods -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[0].resources}{"\n"}{end}' β†’ Verify resource limits.

πŸ’Ύ Investigate Storage Issues

β—† kubectl get pvc β†’ Check PersistentVolumeClaim status.
β—† kubectl describe pvc <pvc-name> β†’ Look for mount failures.
β—† kubectl get events | grep -i volume β†’ Find storage-related errors.

🌐 Find Network Issues

β—‰ kubectl get svc β†’ Verify Service connectivity.
β—‰ kubectl describe endpoints <service-name> β†’ Check if pods are registered.
β—‰ kubectl get ingress β†’ Debug external access problems.

βš™οΈ Track Configuration Issues

◍ kubectl get configmap <cm-name> -o yaml β†’ Detect configuration drift.
◍ kubectl get secret <secret-name> -o yaml β†’ Ensure secrets exist.
◍ kubectl describe deployment <deploy-name> β†’ Check for failed rollout strategies.

🐞 Real-Time Debugging

β—Œ kubectl exec -it <pod-name> -- /bin/bash β†’ Interactive shell for live debugging.
β—Œ kubectl port-forward <pod-name> 8080:80 β†’ Direct local access to the pod.
β—Œ kubectl get pods --watch β†’ Real-time monitoring of pod status changes.