Selecting pods
stern <query>
Tail pods whose name matches regex
stern .
Tail every pod in the namespace
stern <kind>/<name>
Exact resource, e.g. deployment/nginx
Kinds: pod, replicationcontroller, service, daemonset,
deployment, replicaset, statefulset, job.
-n <ns> / --namespace <ns>
Namespace, repeat or comma-separate
-A / --all-namespaces
Every namespace
-l <selector> / --selector
Filter by label selector
--field-selector <expr>
Filter by field, e.g. spec.nodeName=<node>
--node <name>
Pods on one node
--exclude-pod <regex>
Skip pods matching regex
--condition <name[=value]>
Pods by condition, e.g. ready=false
Only works together with --tail=0 or --no-follow.
-p / --prompt
Pick app.kubernetes.io/instance interactively
Containers
-c <regex> / --container
Only containers matching regex
-E <regex> / --exclude-container
Skip containers, e.g. istio-proxy
--container-state <state>
running, waiting, terminated or all
--init-containers=false
Leave out init containers
--ephemeral-containers=false
Leave out ephemeral containers
Output and colour
-o raw
Message text only, no prefix
-o json
One JSON object per line
-o extjson / ppextjson
Extended or pretty-printed JSON
--template '<go-template>'
Custom line format
Fields: Message, Timestamp, NodeName, Namespace, PodName,
ContainerName, Labels, Annotations.
-T <file> / --template-file
Template read from a file
--color auto|always|never
Force or disable colour
Use always when piping into less -R.
-d / --diff-container
Separate colour per container
--pod-colors <sgr,...>
Custom pod colours
--container-colors <sgr,...>
Custom container colours
Cluster and config
--context <name>
Use another kubeconfig context
--kubeconfig <path>
Use another kubeconfig file
--config <path>
Config file, default ~/.config/stern/config.yaml
Also settable with the STERNCONFIG environment variable.
--stdin
Read logs from stdin, colour only
--qps <n> / --burst <n>
Throttle API requests (-1 disables)
--completion bash|zsh|fish
Print shell completion code
-v / --version
Print version
kubectl krew install stern
Install as kubectl plugin