Can't see the pod logs on google GKE
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Google Kubernetes Engine (GKE) is a managed environment for deploying, managing, and scaling containerized applications using Google infrastructure. It's built on Kubernetes, the open-source system for automating deployment. However, managing and debugging applications deployed on GKE can sometimes present challenges, particularly when you're trying to access or view pod logs.
In this article, we'll delve into the common reasons why you might not be able to see pod logs on GKE and address potential solutions.
Understanding Pod Logs in GKE
Pods are the smallest deployable units in Kubernetes, comprising one or more containers. Each pod has its own lifecycle and logs. Viewing these logs is crucial for debugging applications. GKE uses Stackdriver Logging (now integrated into Google Cloud Operations Suite) to manage logs at scale.
Why Can't I See Pod Logs?
- Insufficient Permissions:
- Problem: Lack of the necessary IAM permissions can prevent access to logs.
- Solution: Ensure that your Google Cloud user or service account has the `logging.viewer` or more advanced roles assigned. Use this command to check permissions:
- Problem: If the Stackdriver Logging agent is not properly configured, logs might not be pushed.
- Solution: Verify the `fluentd-gcp` configuration in the `kube-system` namespace using:
- Problem: Kubernetes Engine Logging might be disabled.
- Solution: Check if logging is enabled during cluster creation in the GKE console or using:
- Problem: Pods may have resource limitations affecting log rotation and retention.
- Solution: Set appropriate resource requests and limits in your pod specifications. Here's an example snippet:
- Problem: Incorrect logging levels can filter out the logs of interest.
- Solution: Adjust the log level in your application code or through environmental variables. For most applications, DEBUG or INFO levels are sufficient during development.
- Problem: Network policies may block the logs transmission.
- Solution: Examine and modify network policies accordingly.
Related reading
- Capture Kubernetes Spark driver and executor logs in S3 and view in History Server
- cert-manager.io/v1 Certificate no acme field
- Certificate issued by cert manager reads as issued by cert-manager.local instead of Let's Encrypt and does not work
- cgroups cgroup mountpoint does not exist unknown in gitlab Kubernetes executor
- Can't SSH into AWS EC2 instance
- Capture Heroku SIGTERM in Celery workers to shutdown worker gracefully
- Can't see timestamps in Apache Kafka 0.10.0.0. RC4
- Can't specify the 'async' modifier on the 'Main' method of a console app

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.