Prevent Pod From Endless Restart
When a pod in error state (crashloopbackoff), kubernetes would restart the pod. If you try to exec into the pod to check the log or debug, the following error message appears:
| |
Because the old pod has been killed and you cannot exec into it anymore. So how can we prevent the pod from endless restart?
Just add a command to the deployment yaml to override the default command by the container image. Make the pod never finished by sleep infinity or tail -f /dev/null:
or
Add them to spec.template.spec.containers like this:
Remove the liveness/readiness section from the yaml to make the deployment status green if necessary.
You can exec into the pod to debug as you want.
Reference: