kubectl logs <pod> -n <namespace>Kubernetes Logs and Events Cheat Sheet
Find pod logs, previous container logs, event timelines, kube-system logs, and cluster incident evidence quickly.
Pod Logs
Get logs from a named container
Required for sidecars and multi-container pods.
kubectl logs <pod> -n <namespace> -c <container>Follow logs with timestamps
Stream logs with timestamps for incident reconstruction.
kubectl logs -f <pod> -n <namespace> --timestampskubectl logs <pod> -n <namespace> --tail=200kubectl logs <pod> -n <namespace> --since=30mkubectl logs <pod> -n <namespace> --previousAggregate Logs by Workload
Read logs via deployment resource
Print logs from a workload resource instead of a single pod.
kubectl logs deployment/<name> -n <namespace>kubectl logs job/<name> -n <namespace>Read logs from pods matching a label
Aggregate logs across all containers of pods with a label.
kubectl logs -n <namespace> -l app=<label> --all-containers=true --prefixkubectl logs -n <namespace> -l app=<label> -f --all-containers=true --max-log-requests=20Event Analysis
List namespace events
See the recent warning and normal events in a namespace.
kubectl get events -n <namespace>kubectl get events -n <namespace> --sort-by=.metadata.creationTimestampSort all cluster events by timestamp
Find cluster-wide warnings around the same time window.
kubectl get events -A --sort-by=.metadata.creationTimestampkubectl get events -A --field-selector type=Warning --sort-by=.metadata.creationTimestampShow events for a specific object
Describe an object and inspect its event section.
kubectl describe pod <pod> -n <namespace> | sed -n '/Events:/,$p'System and Control Plane Logs
Read logs from kube-system pods
Aggregate logs from a system component by label.
kubectl logs -n kube-system -l k8s-app=<label> --all-containers=true --prefixList control plane static pods
Check apiserver, scheduler, controller-manager, and etcd pods.
kubectl get pods -n kube-system -o wide | egrep 'apiserver|scheduler|controller-manager|etcd'kubectl logs -n kube-system <kube-apiserver-pod>Read controller-manager logs
Troubleshoot controllers and reconciliation failures.
kubectl logs -n kube-system <kube-controller-manager-pod>kubectl logs -n kube-system <kube-scheduler-pod>Incident Collection
Export object YAML during incident
Capture the exact spec and status for later analysis.
kubectl get <resource> <name> -n <namespace> -o yaml > incident-object.yamlDump cluster info to a directory
Collect cluster state to files instead of stdout.
kubectl cluster-info dump --output-directory=./cluster-dumpSave pod logs to a file
Persist logs for investigation or attachment to a ticket.
kubectl logs <pod> -n <namespace> --all-containers=true > pod.log