Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix EKS cluster detection #1532

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Fix EKS cluster detection #1532

wants to merge 4 commits into from

Conversation

musa-asad
Copy link
Contributor

@musa-asad musa-asad commented Feb 7, 2025

Description of the issue

To detect whether the CloudWatch Agent is running on EKS, we look for a ConfigMap named aws-auth, which is only supported for EKS and maps IAM users/roles to K8s RBAC for API access. However, aws-auth is now deprecated and isn't created on new EKS clusters, which marks the CloudWatch Agent as running on native K8s, not EKS, which is not accurate.

Historically, the server version of an EKS cluster has always contained "eks" (e.g. v1.31.4-eks-2d5f260). We can rely on checking the server version instead of the aws-auth ConfigMap. Based on https://gallery.ecr.aws/eks-distro/kubernetes/kube-apiserver, all previous EKS versions include "eks" in them, so it's a reliable mechanism.

Relevant issue: #1249.

Description of changes

  • Remove logic to query API server for aws-auth.
  • Add logic to query API server for server version.
  • Update unit tests to reflect changes.
    • resetTestState() forces re-evaluation of the IsEKS() singleton for each test.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

Before

Screenshot 2025-02-07 at 1 37 26 AM

After

For testing, added a debug line:
Screenshot 2025-02-07 at 1 40 51 AM

Screenshot 2025-02-07 at 1 35 31 AM

Requirements

Before commit the code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make lint

@musa-asad musa-asad self-assigned this Feb 7, 2025
@musa-asad musa-asad marked this pull request as ready for review February 7, 2025 06:37
@musa-asad musa-asad requested a review from a team as a code owner February 7, 2025 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant