Exercise
This exercise covers common application failure scenarios.
ImagePullBackOff Issues
- Create a Pod with an invalid image name, check the Pod status and describe it.
kubectl run broken-image --image=nginx:nonexistent-tag- Fix the image reference using an existing image
CrashLoopBackOff Issues
- Create a Pod that exits immediately
kubectl run crash-pod --image=busybox --command -- /bin/sh -c "exit 1"- Examine the logs and fix the Pod to keep it running
Documentation
- https://kubernetes.io/docs/tasks/debug/debug-application/debug-pods/
- https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/
Solution
ImagePullBackOff Issues
- Create a Pod with an invalid image name, check the Pod status and describe it.
- creating the Pod
kubectl run broken-image --image=nginx:nonexistent-tag- checking the Pods status shows ImagePullBackOff
kubectl get pod broken-image- describing the Pod gives the origin of the error (image cannot be pulled)
kubectl describe pod broken-image- Fix the image reference using an existing image
kubectl delete pod broken-image
kubectl run broken-image --image=nginx:latestCrashLoopBackOff Issues
- Create a Pod that exits immediately
Command provided in the instructions
- Examine the logs and fix the Pod to keep it running
- getting the Pod shows an CrashLoopBackOff error
kubectl get pods crash-pod- the logs don’t provide any information
kubectl logs crash-pod- describing the Pod shows the exit status 1
kubectl describe pod crash-pod- fixing the specification using another command
kubectl delete pod crash-pod
kubectl run crash-pod --image=busybox --command -- /bin/sh -c "while true; do sleep 30; done"