fix(eksdetector): add IRSA and Pod Identity env var checks before JWT fallback#2107
Open
fix(eksdetector): add IRSA and Pod Identity env var checks before JWT fallback#2107
Conversation
… fallback The EKS detector parses the service account JWT token to check if the issuer contains "eks". This fails on edge cases: custom OIDC providers, opaque tokens, and token mount race conditions at pod startup. Add fast-path env var checks before the JWT fallback: 1. AWS_WEB_IDENTITY_TOKEN_FILE contains "eks.amazonaws.com" (IRSA) 2. AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE contains "eks-pod-identity" (Pod Identity) These are zero-cost checks that cover the two most common modern EKS auth patterns. The existing JWT parsing is preserved as a fallback.
d70c344 to
0cdd9ef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The CWA
eksdetectorparses the JWT token issuer to detect EKS. This fails on:Description of changes
Add fast-path environment variable checks before the existing JWT fallback:
AWS_WEB_IDENTITY_TOKEN_FILE)Important
Co-PRs: amazon-contributing/opentelemetry-collector-contrib#516 — OTEL resource detector 5-step fallback (replaces aws-auth ConfigMap dependency)
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
Setup
Tested on an EKS cluster with
authentication_mode = API(Access Entries only, noaws-authConfigMap present). 1x managed node group (t3.medium). IRSA configured via OIDC provider. Custom CWA image built with this fork change applied via go.mod replace directives. Deployed via mainlineamazon-cloudwatch-observabilityhelm chart with mainline operator.Unit Tests
10 tests (4 existing + 6 new): TestEKS, TestNonEKS, TestEmptyToken, Test_getIssuer, TestEKS_IRSA_EnvVar, TestEKS_PodIdentity_EnvVar, TestEKS_EnvVarsAbsent_FallsThrough, TestNonEKS_EnvVarsAbsent_NonEKSToken, TestEKS_PartialEnvVars_IRSAWithoutEKS, TestEKS_BothEnvVarsSet. All pass.
E2E — CWA eksdetector identifies EKS
Raw eksdetector output from agent logs:
E2E — IRSA env var fast-path exercised
The service account has the IRSA annotation set, which causes EKS to inject
AWS_WEB_IDENTITY_TOKEN_FILEinto the pod via webhook — triggering the env var fast-path before JWT parsing:E2E — ContainerInsights metrics flowing
The CWA eksdetector result gates whether ContainerInsights receivers are configured during config translation. Metrics flowing to CloudWatch confirms
isEKS()returned true via the env var fast-path, enabling the full ContainerInsights pipeline.Metric count: 1154
Metric names:
Sample datapoint (node_cpu_utilization):
{ "Datapoints": [ { "Timestamp": "2026-05-05T19:18:00Z", "Average": 3.892803384167258, "Unit": "Percent" }, { "Timestamp": "2026-05-05T19:17:00Z", "Average": 3.3307807825105575, "Unit": "Percent" }, { "Timestamp": "2026-05-05T19:19:00Z", "Average": 3.495762318338428, "Unit": "Percent" } ], "Label": "node_cpu_utilization" }E2E — Pod stability (0 restarts)