Cloud Intermediate
Kubernetes Debugging¶
KubernetesDebuggingTroubleshooting 3 min read
How to debug problems in Kubernetes. Kubectl commands, events, logs and ephemeral containers.
Basic Debugging¶
# Pod status and events
kubectl describe pod myapp-xyz
kubectl get events --sort-by='.lastTimestamp'
# Logs
kubectl logs myapp-xyz
kubectl logs myapp-xyz --previous # After crashloopback
kubectl logs -l app=myapp --all-containers
# Shell into container
kubectl exec -it myapp-xyz -- sh
# Ephemeral debug container
kubectl debug -it myapp-xyz --image=busybox
Common Problems¶
- CrashLoopBackOff — check logs –previous
- ImagePullBackOff — wrong image name or registry auth
- Pending — insufficient resources (kubectl describe)
- OOMKilled — increase memory limit
Advanced¶
# Network debugging
kubectl run debug --image=nicolaka/netshoot -it --rm -- bash
# DNS test
nslookup my-service.default.svc.cluster.local
# Port forward
kubectl port-forward svc/myservice 8080:80
Summary¶
kubectl describe and logs solve 80% of problems. For network issues, use the netshoot image.
Need Help with Implementation?¶
Our team has experience designing and implementing modern architectures. We’re happy to help.