Logs
Logs – System component logs record events happening in cluster, which can be very useful for debugging.
Print the logs for a pod.
kubectl logs <pod_name>
Print the logs for the last 6 hours for a pod.
kubectl logs --since=6h <pod_name>
Get the most recent 50 lines of logs.
kubectl logs --tail=50 <pod_name>
Get logs from a service and optionally select which container.
kubectl logs -f <service_name> [-c <$container>]
Print the logs for a pod and follow new logs.
kubectl logs -f <pod_name>
Print the logs for a container in a pod.
kubectl logs -c <container_name> <pod_name>
Output the logs for a pod into a file named ‘pod.log’.
kubectl logs <pod_name> pod.log
View the logs for a previously failed pod
kubectl logs --previous <pod_name>
Last updated