Open
Description
When I am troubleshooting a Pod that has crashed or restarted, I want to be able to view the logs from its previous container instance, so I can understand what caused the failure and take corrective action.
With kubectl you can see the logs for a crashed Pod like this:
kubectl logs <pod-name> --previous
kubectl logs <pod-name> -c <container-name> --previous
API:
GET /api/v1/namespaces/{namespace}/pods/{pod}/log?previous=true
previous=true
: fetches logs from the previous container instance, which is useful when the container has crashed or restarted.
We need to design and agree a UI before implementation:
- Maybe an option on the log viewer page?
- Or a separate action "View previous logs" button?
Additional context
See:
- kubectl logs command reference: https://kubernetes.io/docs/reference/kubectl/generated/kubectl_logs/
- Debugging running or crashing pods: https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/
- Logging architecture overview (includes --previous usage): https://kubernetes.io/docs/concepts/cluster-administration/logging/
- For example yaml to make a Pod terminate "termination-demo" https://kubernetes.io/docs/tasks/debug/debug-application/determine-reason-pod-failure/
This was one of the most requested features in dashboard: kubernetes/dashboard#1393 https://github.com/kubernetes/dashboard/pull/2392/files and is a commonly used feature of kubectl.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Queued