Kubernetes β€’ Debug & Inspection

How to Stream Live Logs from Kubernetes Pods and Deployments

`kubectl logs` streams log lines directly from the container runtime (containerd/CRI-O). Using label selectors (`-l app=my-app`) aggregates log streams from all running pod replicas simultaneously.

Stream Live Pod Logs Command
Safe β€’ Read-Only / Non-Destructive
kubectl logs -f -l app=my-app -n default --max-log-requests=10 --tail=100
Customize:
Namespace:
Resource Name:

Flags & Parameter Breakdown

-f, --followStream logs continuously in real-time (like tail -f)
-l <label-selector>Stream logs from all pods matching the selector
--tail=<n>Number of recent lines to display (default: all)
--timestampsPrefix each log line with an RFC3339 timestamp

Step-by-Step Execution Workflow

1Follow single pod logs

Stream logs from a specific pod:

kubectl logs -f my-pod -n default
2Stream logs across all deployment replicas

Follow logs from every pod matching app label:

kubectl logs -f -l app=my-app -n default --tail=100
3Add timestamps to diagnose latency

Include exact timestamps with each log line:

kubectl logs my-pod -n default --timestamps --tail=50

Common Pitfalls & Troubleshooting Advice

  • If using `-l` across many pods, set `--max-log-requests=10` or more if some pods are omitted.
  • For complex multi-pod log filtering with regex and color coding, tools like `stern` are highly recommended.

Prerequisites & Cluster Access

  • Pods must have published logs to stdout or stderr.

Frequently Asked Questions About Stream Live Pod Logs

Frequently Asked Questions

Frequently Asked Questions

Everything you need to know regarding specifications, syntax, and security best practices.

Add `-c <container-name>`: `kubectl logs -f my-pod -c api-gateway -n default`.