How to debug a failing Deployment?
· Category: Kubernetes
Short answer
Debug a failing Deployment by checking rollout status, describing the Deployment and ReplicaSet, inspecting Pod events and logs, and verifying resource and image availability.
Steps
- Check rollout status:
kubectl rollout status deployment/name. - Describe the Deployment for events.
- Inspect the ReplicaSet and Pods.
- Check logs and events.
- Verify image tags, secrets, and resource quotas.
Example
kubectl get deployment myapp
kubectl describe deployment myapp
kubectl get rs -l app=myapp
kubectl describe pod myapp-xxx
kubectl logs myapp-xxx
kubectl get events --sort-by='.lastTimestamp'
Tips
- Use
kubectl get eventsto see scheduling and image pull errors. - Use
kubectl rollout undoto quickly revert a bad deployment. - Check
kubectl top podfor resource exhaustion.
Common issues
ImagePullBackOffmeans the image is missing or inaccessible.CrashLoopBackOffmeans the container exits immediately.Pendingmeans insufficient resources or node constraints.FailedCreateoften indicates quota or RBAC issues.