liveBook · Manning

Kubectl logs

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

kubectl logs is a kubectl command that retrieves container logs from a Kubernetes pod.

kubectl logs retrieves container logs from a Kubernetes pod. Use it as a practical starting point for inspecting a microservice running in a cluster. section 11.2.4

Retrieve a pod's logs

Find the pod's unique Kubernetes-generated name, then replace the placeholder with that name. For example, a metadata microservice might use a name such as metadata-55bb6bdf58-7pjn2. section 11.2.4

kubectl logs <pod-name>

Use the command template kubectl logs <pod-name> with the actual pod name from the cluster. section 11.2.4

For multiple replicas or continuously streaming logs, Stern can match pods by partial name; the Kubernetes dashboard offers visual inspection of pod logs and other resources. section 11.2.4

How Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform covers it

How deep it goes
Demonstrates the basic pod-name command, then defers multi-replica and ongoing collection to Stern.
Examples
Uses the metadata microservice pod and contrasts kubectl logs with stern metadata.
What it assumes
Assumes access to a Kubernetes cluster and a pod name, while teaching log retrieval from a command template.
What you can do after
Operate kubectl logs by replacing its pod-name placeholder with an actual Kubernetes pod name.
How it connects
Connects pod logs with Kubernetes pods, microservices, Stern, and the Kubernetes dashboard.

Also explained in

Compare how 3 books explain kubectl logs →

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.