How to find the reason of a pod crashing? How to find the reason of a pod crashing? kubernetes kubernetes

How to find the reason of a pod crashing?


Try looking at the Kubernetes events kubectl get events --sort-by='.lastTimestamp'

If you don't get anything meaningful out of events go to the specific node and see the kubelet logs journalctl -u kubelet


To get logs from a pod you should use:

kubectl logs [podname] -p

You can also do kubelet logs but that's mostly for Cluster logs.

If there is no logs that means your application did not produces any logs before the crash. You would need to rewrite the app and for example add a memory dump on crush.

You mentioned that the pod is dying under heavy load but stats shows only 50% utilization. You should login to the pod and check yourself the load, maybe check how many files are being open because maybe you are hitting the limit.

You can read the Kubernetes docs about Application Introspection and Debugging and go over Debugging CrashLoopBackoffs with Init-Containers.

You can also try running your image in Docker and checking logs there. There is a nice documentation about Logs and troubleshooting available.

If you provide more details we might be more helpful.


Below are some obvious reasons for crashloopbackoff, which I have observed:

  1. waiting for some condition to be full-filled e.g. some secrets,failing healthcheck etc
  2. pod is running with burstable or besteffortQoS and is getting killed due to non-availability of resources onnode

You can run this script to find the possible issues for pods in a namespace: https://github.com/dguyhasnoname/k8s-day2-ops/blob/master/namespace_scripts/debug_app_namespace.sh