Interview Prep/Kubernetes/EKS-specific issues

An app using IRSA fails with `AccessDenied: Not authorized to perform sts:AssumeRoleWithWebIdentity`.

AdvancedTroubleshootingEKS-specific issues
Answer

Likely causes → The role's trust policy does not match the token: wrong OIDC provider ID (cluster recreated), the IAM OIDC provider is missing, or the sub condition names a different namespace or ServiceAccount (system:serviceaccount:payments:api).

Diagnose →

aws eks describe-cluster --name prod --query 'cluster.identity.oidc.issuer' --output text
aws iam list-open-id-connect-providers
aws iam get-role --role-name payments-api --query 'Role.AssumeRolePolicyDocument'
kubectl get sa api -n payments -o jsonpath='{.metadata.annotations.eks\.amazonaws\.com/role-arn}{"\n"}'

Fix → Create the IAM OIDC provider for the cluster and correct the trust policy:

"Condition": {"StringEquals": {
  "oidc.eks.ap-south-1.amazonaws.com/id/ABC123:sub": "system:serviceaccount:payments:api",
  "oidc.eks.ap-south-1.amazonaws.com/id/ABC123:aud": "sts.amazonaws.com"}}

Prevent → Generate IRSA roles with the cluster in IaC, or switch to EKS Pod Identity, which has no per-cluster OIDC trust to maintain.

All Kubernetes questions

More on EKS-specific issues