View log files of crashed pods in kubernetes

Assuming that your pod still exists:

kubectl logs <podname> --previous

$ kubectl logs -h
-p, --previous[=false]: If true, print the logs for the previous instance of the container in a pod if it exists.


There was a bug in kubernetes that prevents logs obtaining for pods in CrashLoopBackOff state. Looks like it was fixed. Here issue on github with additional information


kubectl logs command only works if the pod is up and running. If they are not, you can use the kubectl events command.

kubectl get events -n <your_app_namespace> --sort-by='.metadata.creationTimestamp'

By default it does not sort the events, hence the --sort-by flag.