Skip to content
Latchkey

stern: Tail Logs Across Multiple Namespaces

stern -A (or --all-namespaces) tails matching pods in every namespace at once, with the namespace shown in each line prefix.

When a request crosses several namespaces (ingress, app, sidecar), watching one namespace hides half the story. stern can span them in a single stream.

What it does

stern reads pods from one namespace by default. -A/--all-namespaces widens it to the whole cluster, and -n can be repeated to name a specific subset. A label selector with -l narrows the match further than the name regex alone.

Common usage

Terminal
stern -A ingress              # every namespace
stern . -n app -n payments    # two explicit namespaces
stern -l app=api -A           # by label across all namespaces

Options

FlagWhat it does
-A, --all-namespacesWatch pods in every namespace
-n, --namespaceNamespace; may be repeated for several
-l, --selectorLabel selector, e.g. app=api,tier=web
--field-selectorField selector, e.g. status.phase=Running
--exclude-podRegex of pod names to skip

Common errors in CI

pods is forbidden: User ... cannot list resource "pods" in API group "" at the cluster scope means -A needs a ClusterRole the CI token lacks; list namespaces explicitly with -n instead. An empty stream with no error usually means the label selector matched nothing; verify with kubectl get pods -A -l <selector>.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →