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/binand go - Obeys
$KUBECONFIGand--context, same as kubectl - Shell completions via
stern --completion=bash|zsh|fish - Configurable templates (
--template) for log prefixes - Plays well with
fzffor interactive Pod selection in a shell alias
Key Features
- Regex and label selectors with
--selector - Container-state filter — show init, sidecars, or just running
--promptwraps 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.