feat(support): diagnose-install checks EKS Pod Identity for every ServiceAccount the release uses
What
scripts/support/diagnose-install.py checks EKS Pod Identity coverage whenever it runs with a cluster scope.
-
Which ServiceAccounts need AWS. It reads the release's Deployments, StatefulSets, Jobs and CronJobs (
app.kubernetes.io/instance=<release>). A ServiceAccount counts when its pods read S3 (LOCKER_BUCKETwith no staticLOCKER_ACCESS_KEY_ID) or sign OpenSearch requests (SEARCH_INDEX_OPENSEARCH_AUTH=sigv4). It checks the release as rendered, not a fixed list. From the templates, the EKS profiles render:ServiceAccount Workloads (0.7.54 / 0.7.81 render) Needs agent-relay-workersession-summary/status/metadata workers, worker-migrateJobS3 read/write agent-relay-session-ingest-apiingest edge S3 read/write agent-relay-search-indexersearch indexer + bootstrap Job S3 read, OpenSearch write agent-relay-session-readread API S3 read, OpenSearch read agent-relay-alleyoopnot rendered by values-eks-native.yaml; only legacy profilesS3 read/write -
Associations. It runs
aws eks list-pod-identity-associations --cluster-name … --region … --namespace …. The cluster and region come from the EKS kube context: the cluster ARN, or the exec plugin's--cluster-name/--regionandAWS_PROFILE.--eks-clusterand--aws-regionoverride them. Each missing association is a FAIL whose next step is the exactaws eks create-pod-identity-associationline. The role is the one a ServiceAccount with the same access already uses; if there is none, it's a placeholder naming the access. The next step also includesrollout restartfor that ServiceAccount's Deployments. Associations no workload uses (hereagent-relay-alleyoop) are listed for information. -
Stretch: role reach. For each association it runs
aws iam simulate-principal-policyagainst the bucket (arn:aws:s3:::<bucket>and/*) and the OpenSearch domain parsed fromSEARCH_INDEX_OPENSEARCH_URL. If the caller may not simulate, the result is UNKNOWN. The simulation covers identity policies only; the docs say so.
All AWS calls are reads. Without AWS credentials, each ServiceAccount is UNKNOWN with the list command to run. --no-aws and --no-iam-simulate skip the section. Raw AWS errors never reach the report, only fixed categories, which matches the script's existing rule.
Docs. docs/self-hosted-eks.md gets the ServiceAccount → access table and a pre-install MISSING check. docs/support/diagnose-install.md gets an EKS Pod Identity section.
Terraform. terraform/examples/aws-existing-cluster (used by the EKS guide) and terraform/examples/aws already associate worker, alleyoop and session-ingest-api with the sessions role, and modules/aws/search associates search-indexer and session-read. aws-environments covers the worker too. No change needed.
Output (rehearsal shape: no worker association)
This is a real run of main() with kubectl/aws stubbed to the rehearsal's state. I couldn't reach a real EKS account from here.
PASS podidentity.agent-relay-search-indexer [agent-relay-search-indexer]: Pod Identity association exists (role arn:aws:iam::123456789012:role/session-indexer); needs S3 read, OpenSearch write.
PASS podidentity.agent-relay-search-indexer.s3-r [agent-relay-search-indexer]: S3 read: the role's IAM policy allows it.
PASS podidentity.agent-relay-search-indexer.os-w [agent-relay-search-indexer]: OpenSearch write: the role's IAM policy allows it.
PASS podidentity.agent-relay-session-ingest-api [agent-relay-session-ingest-api]: Pod Identity association exists (role arn:aws:iam::123456789012:role/session-ingest-api); needs S3 read/write.
...
FAIL podidentity.agent-relay-worker [agent-relay-worker]: No Pod Identity association for ServiceAccount agent-relay-worker (used by agent-relay-worker-session-summary-worker, agent-relay-worker-migrate-6ae46510), which needs S3 read/write. Its pods get no AWS credentials.
Next: aws eks create-pod-identity-association --cluster-name demo --region us-west-2 --namespace agent-relay --service-account agent-relay-worker --role-arn arn:aws:iam::123456789012:role/session-ingest-api then restart its pods: kubectl -n agent-relay rollout restart deployment/agent-relay-worker-session-summary-worker
PASS podidentity.unused: Associations no workload of this release uses (harmless; remove if unwanted): agent-relay-alleyoop.
Tests
python3 -m unittest discover -s scripts/support/tests -p 'test_*.py': 45 passed (8 new). They cover the exact fix line and role reuse, the access levels, the simulated resource ARNs, deny → FAIL, AccessDenied on simulate → UNKNOWN, no credentials → UNKNOWN without the raw error, the placeholder role, static keys and non-S3 providers, the cluster from flags, ARN and exec args, and --no-aws.
Coordination
#553 also edits diagnose-install.py (cluster_checks ConfigMaps, values_checks rds-ca). This PR doesn't touch either function. The new code sits after database_checks, and its only hook is in main. The helm test status table (#554) is separate.
Site docs (table plus association check in the EKS guide) are in a separate agentrelay.com PR that doesn't depend on this one.
🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
diagnose-install.py now checks EKS Pod Identity coverage for every ServiceAccount the release's workloads run as, so a missing association is reported at install time instead of surfacing later as "no Locker credentials" pod errors.
Details
- Finds the ServiceAccounts the release's Deployments, StatefulSets, Jobs, and CronJobs use for S3 (
LOCKER_BUCKETwithout static keys), the S3 re-arm sweeper (INGEST_REARM_CREDENTIALS=podIdentity), or OpenSearch (SEARCH_INDEX_OPENSEARCH_AUTH=sigv4), with the access level each needs; only the access a workload actually uses is checked. - Lists the namespace's associations, reading the cluster, region, and
AWS_PROFILEfrom the kube context (--aws-profile,--eks-cluster, and--aws-regionoverride them); non-EKS contexts skip the section. - FAILs each missing association with the exact
create-pod-identity-associationline (reusing a role that already has the same access; never the ingest edge's role under direct uploads) plus the--contextrollout restartfor its Deployments; associations no workload uses are listed for information only. - Optionally runs
iam simulate-principal-policyper role against the search module's S3/OpenSearch action sets, covering identity policies only; a blocked simulation or unreadable role is UNKNOWN. - All AWS calls are reads. Without credentials each ServiceAccount is UNKNOWN with the command to run;
--no-awsand--no-iam-simulateskip the section.
Docs gain the ServiceAccount → access table, a pre-install association check, and a diagnose-install.md section. The Terraform examples already associate the worker; no Terraform change. 13 new tests.