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

Merged
merged 11 commits into from
Feb 11, 2025
Merged

Fix EKS cluster detection #1532

merged 11 commits into from
Feb 11, 2025

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.

A suggestion from an issue is to inspect the serviceaccount token and look for the issuer field (iss). It contains the unique OIDC url for the EKS cluster.

Relevant issue: #1249.

Description of changes

  • Add logic to query API server for issuer field as a fall-back.
  • 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-11 at 1 21 30 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
@musa-asad musa-asad merged commit 799f0c3 into main Feb 11, 2025
7 checks passed
@musa-asad musa-asad deleted the server-version branch February 11, 2025 21:01
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.

3 participants