# Stern — Multi-Pod Multi-Container Log Tailing for Kubernetes > The missing multi-Pod tail -f for Kubernetes. Follows every matching Pod and container with color-coded names — the first tool SREs install after kubectl. ## Install Save in your project root: # Stern — Multi-Pod Multi-Container Log Tailing for Kubernetes ## Quick Use ```bash # install on macOS / Linux brew install stern # or: go install github.com/stern/stern@latest # tail every Pod matching a regex, across all namespaces stern '.*' -A # tail one deployment's containers with color-coded Pod names stern --selector app=checkout --since 10m # include init containers, exclude debug sidecars, JSON output stern checkout-* --container-state all --exclude-container istio-proxy -o json # follow only error lines stern payments -i 'ERROR|panic' ``` ## Introduction Stern is the missing multi-Pod `tail -f` for Kubernetes. Where `kubectl logs` can only tail one Pod's one container, Stern glues every matching Pod and every container together into a single colored stream. It is the first thing most SREs install after kubectl, and one of the few tools that works identically on kind, EKS, and air-gapped clusters. ## What Stern Does - Tails logs from multiple Pods and containers with a single regex or label selector - Color-codes Pod names so interleaved logs stay readable - Follows rolling deployments — new Pods are picked up automatically - Supports time windows (`--since`, `--tail`) and include/exclude regexes - Emits JSON or raw output for pipelines into `jq`, Loki, or a file ## Architecture Overview Stern is a small Go binary. It talks to the Kubernetes API via your kubeconfig, watches Pods matching the query, and opens a streaming log request against each matched container. It maintains a concurrency-safe writer that interleaves lines with a Pod prefix; when Pods come and go (restarts, rollouts, preemption) Stern silently reattaches without dropping the overall session. ## Self-Hosting & Configuration - Single static binary — drop into `/usr/local/bin` and go - Obeys `$KUBECONFIG` and `--context`, same as kubectl - Shell completions via `stern --completion=bash|zsh|fish` - Configurable templates (`--template`) for log prefixes - Plays well with `fzf` for interactive Pod selection in a shell alias ## Key Features - Regex and label selectors with `--selector` - Container-state filter — show init, sidecars, or just running - `--prompt` wraps stern with an fzf-based interactive picker - JSON output mode feeds structured-log stores directly - Works across namespaces with `--all-namespaces` / `-A` ## Comparison with Similar Tools - **kubectl logs** — single Pod / container only; Stern is the multi-stream upgrade - **kail** — older, similar tool; less active maintenance - **kubetail** — bash script wrapper; fine for small clusters but lacks streaming - **Loki + logcli** — centralized store; great for history, not for live tailing - **k9s log pane** — built into k9s but one Pod at a time ## FAQ **Q: How is this different from kubectl logs -f?** A: Stern streams every matching Pod and container concurrently, with colored prefixes. kubectl logs targets one. **Q: Can I tail across namespaces?** A: Yes — `-A` or `--all-namespaces` scopes across the whole cluster (subject to RBAC). **Q: Does it support kube-proxy or private clusters?** A: Yes — whatever your kubeconfig can reach, Stern can stream from. **Q: How do I filter noisy sidecar logs?** A: `--exclude-container istio-proxy,linkerd-proxy` drops them from the stream. ## Sources - https://github.com/stern/stern - https://github.com/stern/stern#installation --- Source: https://tokrepo.com/en/workflows/f3a966bd-3900-11f1-9bc6-00163e2b0d79 Author: AI Open Source