Skip to main content
In this lesson, we walk through a comprehensive lab that focuses on managing application logs using Kubernetes. The lab covers two important scenarios: one diagnosing user login issues and the other addressing issues during an item purchase within a multi-container web application. By leveraging Kubernetes commands and log inspection, you will learn how to quickly identify and resolve problems.

Scenario 1: Diagnosing User Login Issues

Initially, we deployed a Pod hosting the application. To verify that the Pod is running, execute the following command:
The expected output should resemble:
When USER5 reported login issues, we inspected the application logs to diagnose the problem. The logs revealed repeated failed login attempts by USER5, which resulted in the account being locked. Below are the log entries outlining the sequence of events:
The logs make it clear that multiple failed login attempts by USER5 have caused an automatic account lock. This is an essential diagnostic detail when troubleshooting login issues.

Scenario 2: Handling Logs in a Multi-Container Pod

A second application was deployed involving two Pods. To confirm the deployment and status of these Pods, run:
You should now see two Pods listed:
When inspecting the logs for the second Pod (webapp-2), an error occurs because the Pod contains two containers. Attempting to view the logs without specifying a container name results in this error:
This message indicates that you must specify the container name—either “simple-webapp” or “db”—to view the relevant logs. For examining the web application behavior, you should use the container that manages the web service (typically “simple-webapp”). Next, to diagnose an item purchase failure, we analyze the logs for clues. A user reported an issue during the purchase process. The log entries below help pinpoint the problem:
From the above logs, it is evident that USER30 encountered an issue—the order failed because the item was out of stock. This warning, together with the login failure for USER5, highlights two separate issues within the application.

Summary

By inspecting the logs and using the appropriate Kubernetes commands, we successfully identified the key issues:
  • In the first scenario, USER5 experienced login failures due to repeated failed attempts that resulted in an account lock.
  • In the second scenario, USER30 was unable to complete an order because the item was out of stock. Additionally, remember to specify a container name when retrieving logs from Pods with multiple containers.
Happy logging and troubleshooting!

Watch Video