Gonzalo
Gonzalo

Reputation: 369

Kubernetes Pods failed hours ago, how to debug a terminated pod

I have a deployment of pods which failed 22h ago, how often does Kubernetes log-rotate its logs?

Is there any possibility to view the logs of the deployment but 22 hours ago?

Thanks

Upvotes: 0

Views: 2423

Answers (4)

Apoorva Saxena
Apoorva Saxena

Reputation: 9

These logs cannot be retrieved, if you have stored these logs in newrelic or someplace then you can filter with service name and pod name to retrieve the last logs that exist for this pods

Upvotes: 0

Vit
Vit

Reputation: 8411

  1. Kubernetes does NOT provide built-in log rotation.

  2. Check official Debug Running Pods documentation:

If your container has previously crashed, you can access the previous container's crash log with:

kubectl logs --previous ${POD_NAME} ${CONTAINER_NAME}
  1. In my opinion you are asking not about logs on pod, you are more interested in full debug. Your starting point is again official documentation Troubleshoot Applications-Debugging Pods. ANd start check with kubectl describe pods ${POD_NAME}

4.All I wrote above is great, however sometimes the only way to get the logs is @confused genius answer.

Upvotes: 0

rassakra
rassakra

Reputation: 1121

You can use kubectl logs --previous to retrieve logs from a previous instantiation of a container.

Upvotes: 0

confused genius
confused genius

Reputation: 3244

I think we can not retrieve logs from a pod that is not in ready state. We can get the logs of the container inside the pod , By logging into the worker node where pod was running .

  • docker ps -a | grep <pod name>
  • docker logs <container name/id from above output

Upvotes: 1

Related Questions