- Identify a user issue from logs for a single-container Pod.
- Handle Pods with multiple containers when viewing logs.
1) Inspect a single-container Pod and identify the issue
Steps to inspect logs for a Pod that contains a single container:- Confirm the Pod is running:
- View the application logs for the Pod:
- Look for repeated WARNING entries. Here, multiple WARNINGs indicate USER5 repeatedly failed to log in.
- The log message clearly states the reason: the account is locked due to many failed login attempts.
- USER5 cannot access the application because their account is locked after too many failed login attempts.
2) Inspect logs for a multi-container Pod and identify the issue
When a Pod runs more than one container, you must specify which container’s logs you want to read. If you run the logs command without a container name:webapp and db). To read logs from the web application container, include -c with the container name:
webapp container:
- This webapp container log includes WARNING entries for two different user-related issues:
- USER5: repeated failed logins because the account is locked.
- USER30: order failure due to an item being out of stock.
- The purchasing problem reported by users is represented by the USER30 warnings: the item is OUT OF STOCK.
When a Pod has multiple containers, always use
kubectl logs <pod> -c <container> to select which container’s logs you want to read.Quick reference
Summary
- Single-container Pod: Inspect logs with
kubectl logs <pod-name>. From the sample logs, USER5 cannot access the app because their account is locked after too many failed login attempts. - Multi-container Pod: Specify the container with
-c(for example,kubectl logs webapp2 -c webapp). From the webapp container logs, the purchase failures are caused by items being OUT OF STOCK (USER30).