Difficulty: Beginner
Estimated Time: 15 minutes

Logs on Vancouver River, Tony Hisgett, Flickr

Kubernetes Logging

Traditionally, applications on servers generate logs that are often routed to /var/log. Container runtime engines and Kubernetes also produce logs in the same location, but there are considerations when applications are scaled and replicated across many nodes in your cluster. The Kubernetes API has techniques to obtain these logs. These are solid techniques for debugging and spot checking. Production level observability includes patterns that use DaemonSets and Sidecars to collect and stream these logs to other data stores optimized for persistence and queries.

This scenario explores the basic techniques for inspecting the logs generated by Kubernetes and containers distributed across your cluster.

In the following steps you will learn how to:

  • ensure your application generates logs to streams,
  • inspect Kubernetes cluster events,
  • inspect container logs across multiple Pods,
  • use some convenient command-line tools to view log aggregations.

The scenario introduced some fundamental techniques to inspecting events and application logs on Kubernetes. Because Kubernetes is distributed, you cannot just inspect logs found in a single directory.

Beyond this scenario, explore techniques to automate log aggregation and synchronization. Logs are stored in the /var/log/container and /var/log/pods directories, which as considered ephemeral. DaemonSets on the Nodes and Sidecars in the Pods can centralize and sync these logs to other services. The other services, like Elasticsearch, offer reliable long-term persistence, rich queries, and automatic alerting based on the rules often defined by Site Reliability Engineers (SREs). As a next step, explore the Logging with EFK scenario.

Lessons Learned

With these steps you have learned how to:

  • ✔ ensure your 12-factor application generates logs to streams,
  • ✔ inspect Kubernetes cluster events,
  • ✔ inspect container logs across multiple Pods,
  • ✔ use some convenient command-line tools to view log aggregations.

References


For a deeper understanding of these topics and more join
Jonathan Johnson
at various conferences, symposiums, workshops, and meetups.

Software Architectures ★ Speaker ★ Workshop Hosting ★ Kubernetes & Java Specialist

Kubernetes Logging

Step 1 of 5

Your Kubernetes Cluster

For this scenario, Katacoda has just started a fresh Kubernetes cluster for you. Verify it's ready for your use.

kubectl version --short && \ kubectl get componentstatus && \ kubectl get nodes && \ kubectl cluster-info

The Helm package manager used for installing applications on Kubernetes is also available.

helm version --short

Kubernetes Dashboard

You can administer your cluster with the kubectl CLI tool or use the visual Kubernetes Dashboard. Use this script to access the protected Dashboard.

token.sh