← ClaudeAtlas

stern-logslisted

Read, filter and search Kubernetes pod logs with stern — the multi-pod, multi-container log tailer. Use whenever the task involves looking at logs from a Kubernetes cluster: debugging a failing deployment, checking why pods crash-loop, grepping errors across a namespace, following a rollout, or correlating logs across several pods. Trigger phrases: "check the logs", "tail the logs", "why is this pod failing", "grep the errors in namespace X", "看一下 log", "查 k8s 的 log", "stern", "kubectl logs but for many pods", "logs across all pods of deployment/service", "CrashLoopBackOff logs". Also covers stern's Go templates for reformatting JSON application logs and `--stdin` for replaying a local log file through those templates. NOT for writing application logging code, not for log aggregation backends (Loki/ELK/CloudWatch queries), and not a replacement for `kubectl get`/ `describe` when the question is about pod state rather than log content.
shyuan/skills · ★ 5 · DevOps & Infrastructure · score 74
Install: claude install-skill shyuan/skills
# stern `stern` tails logs from **many pods and many containers at once**, selected by a regex or a Kubernetes resource, with automatic pickup of new pods and colorized per-pod output. ## Iron Law ``` In an agent/non-interactive context, every stern invocation carries --no-follow. ``` Without it stern **streams forever and never exits** — the tool call blocks until the harness timeout, and the partial output may be discarded. The only exception: the user explicitly asked to watch a live stream, and it runs as a background command with a stated stop condition. The second half of the law: **bound the volume**. The defaults are `--since 48h` and `--tail -1` (*every* line ever retained), multiplied by every matching pod. Always narrow at least one of `--tail` / `--since` — and **both** once the query spans more than a handful of containers, since they are what truncates each stream. Narrowing *which* containers are read at all (`-E`, `--exclude-pod`, `-l`, a tighter query) saves more and costs nothing; line filters save neither. ### Rationalization table Every one of these will occur to you mid-task. All of them are wrong. | The thought | Reality | |---|---| | "This namespace only has two pods, streaming is fine." | Pod count does not make stern exit. Two pods stream forever just as well as fifty. | | "The user said 'watch'/'monitor'/'看一下現在的狀況', so they want live output." | They want an *answer*. `--no-follow --since 5m` gives it. Streaming into a blocked tool call gives