Stern is a command-line tool for retrieving and following logs from multiple Kubernetes pods using name or label patterns.
Stern retrieves logs from Kubernetes pods without requiring each pod’s generated full name. A partial name matches pods across replicas, making microservice log inspection faster. section 11.2.4
Use Stern when you need to:
Match pods by a partial microservice name. section 11.2.4
Collect logs from multiple replicas at once. section 11.2.4
Follow ongoing log output until stopping the command with Ctrl-C. section 11.2.4
Follow metadata service logs
Run `stern metadata` to match pods whose names start with `metadata` and continuously display their logs. This avoids looking up Kubernetes-generated pod names and includes multiple replicas. section 11.2.4
stern metadata
Browse the complete Stern command used to follow logs for metadata pods. section 11.2.4
How Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform covers it
How deep it goes
Explains partial-name matching, replica coverage, and continuous output, while deferring installation and broader usage instructions.
Examples
Uses `stern metadata` to follow logs from metadata microservice pods and their replicas.
What it assumes
Assumes a Kubernetes cluster containing the target microservice pods and familiarity with kubectl-based log retrieval.
What you can do after
Operate Stern to retrieve and continuously follow logs from one or more Kubernetes microservice pods.
How it connects
Connects Stern with Kubernetes pods, kubectl logs, microservices, replicas, and the Kubernetes dashboard.
poduses · A Kubernetes Pod is the smallest deployable unit in Kubernetes, grouping one or more co-located containers that share networking and other resources.
kubectl logsalternative to · A kubectl command that retrieves log output produced by containers in a Kubernetes pod.
This explainer was generated by Manning's knowledge graph from the text of Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform. The section links point to the parts of the book it draws on.