0

My k8s pod gets terminated/crashed sometimes and restarts automatically. When I try to see the old log to debug for the crash, I get the below error. If terminated container not found, then how can I get the log and debug the crash in this case?

My pod has only one container inside it.

/home/ravi> sudo kubectl logs -p mypod-766c995f8b-zshgc -n ricplt 
Error from server (BadRequest): previous terminated container "container-ricplt-e2term" in pod "mypod-766c995f8b-zshgc" not found

1 Answers1

1

I recommend you to use tool like LENS to have a GUI to have a clarity on what is going on in K8S cluster.Also you can use kubectl get events to know the history of events happened along with age of event,pod info , etc. It can help you to know for what reason the old container has been terminated.

  • but even though we will not able to get log when crash happened and it will be a problem – myquest9 sh Aug 25 '23 at 10:06
  • You have not detailed the error in your comment. In my case get events helped me. Also you mentioned that doesn't help in your case. Then you should focus on configuring proper monitoring services for tracking. Refer link to find some suggestions. https://stackoverflow.com/questions/57007134/how-to-see-logs-of-terminated-pods – Suresh Ganesan Aug 25 '23 at 13:10