Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theaws-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.Description of changes
aws-auth
.resetTestState()
forces re-evaluation of theIsEKS()
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
After
For testing, added a debug line:
![Screenshot 2025-02-07 at 1 40 51 AM](https://private-user-images.githubusercontent.com/165414028/410791364-179ba31f-ecc6-4398-bd8b-86f4db66e8c3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNTM4OTAsIm5iZiI6MTczOTA1MzU5MCwicGF0aCI6Ii8xNjU0MTQwMjgvNDEwNzkxMzY0LTE3OWJhMzFmLWVjYzYtNDM5OC1iZDhiLTg2ZjRkYjY2ZThjMy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOFQyMjI2MzBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xMzg0ZTIxMDI3ZGFkNGM2YWZiY2VhOTFlODdmZmNiYmI1M2NhNjEyNDcxZWIyOTFmMzY4MTljMzUxZTdjZmRhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.7LX8egYl-L9BoA5SrzGBSZ8TbAceTl6GnCfucUriJrc)
Requirements
Before commit the code, please do the following steps.
make fmt
andmake fmt-sh
make lint