liveBook · Manning

Stern

As explained in Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform

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:

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.

Related concepts

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.