How to get k8s master logs on EKS?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Amazon Elastic Kubernetes Service (EKS) is a managed Kubernetes service that makes it easy to run Kubernetes on AWS without needing to install and operate your own Kubernetes control plane or nodes. However, when it comes to debugging issues, accessing logs is crucial. In this article, we'll delve into how you can obtain the Kubernetes (k8s) master logs on EKS.
Understanding Kubernetes Master Components
Before we discuss retrieving these logs, it's essential to understand the Kubernetes master components:
- API Server: This component is the front-end of the control plane, exposing the Kubernetes API.
- Etcd: A consistent and highly-available key-value store used for all cluster data.
- Controller Manager: Ensures the cluster's desired state by handling routine tasks.
- Scheduler: Schedules the pods on available nodes.
Why Retrieve Master Logs?
Accessing the logs of the master components can provide insights into various operations, including:
- Debugging API server issues.
- Analyzing cluster state changes.
- Understanding scheduling logic.
- Tuning performance metrics.
Accessing EKS Master Logs
In EKS, AWS manages the control plane, and these master components are not directly accessible. Thus, traditional methods of logging into a master node to view log files aren't applicable. Nevertheless, you can obtain these logs using AWS CloudWatch and the EKS API.
Steps to retrieve EKS master logs
Step 1: Enable Control Plane Logging
To retrieve master logs, you first need to enable logging via AWS Management Console, AWS CLI, or AWS SDKs.
Using AWS Management Console:
- Navigate to the EKS service.
- Click on the cluster name.
- Go to the "Logging" tab.
- Select the types of logs you wish to enable:
- API Server
- Audit
- Authenticator
- Controller Manager
- Scheduler
- Click on "Update Logging".
Using AWS CLI:
/aws/eks/<cluster-name>/cluster/api/aws/eks/<cluster-name>/cluster/audit- Navigate to the API log group in CloudWatch.
- Use log filters to search for specific error messages or HTTP status codes.
- Analyze the sequence of API calls leading to the error for context.
- Log Retention: By default, logs in CloudWatch are kept indefinitely. Adjust the retention policy if needed to manage costs.
- Automation: Use AWS Lambda with CloudWatch for automated alerts based on log patterns.
- Security: Ensure access to CloudWatch logs is controlled via IAM policies.
Related reading
- How to get Kubernetes cluster name from K8s API
- How to get kubernetes service account access token using fabric8 java client?
- How to get logs of deployment from Kubernetes?
- How to get logs of two pods without opening two terminals and using kubectl tail command?
- How to get public URL after uploading image to S3?
- how to get return response from AWS Lambda function
- How to get number of pods running in prometheus
- How to get pods under the service with client-go the client library of kubernetes?

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.