Sub topic 11
EKS Pod Identity as an alternative
This chapter assumes you have read the IRSA chapter. You should know what an IAM role trust policy is and how a ServiceAccount maps to a role. EKS Pod Identity gives Pods AWS credentials without per-cluster OIDC provider setup.
How it differs from IRSA
IRSA exchanges a projected ServiceAccount token for credentials by calling sts:AssumeRoleWithWebIdentity. The trust policy names your cluster's OIDC provider, so every cluster needs its own provider and its own trust conditions.
Pod Identity moves that mapping into the EKS API. You create an association between a namespace, a ServiceAccount, and an IAM role. A DaemonSet called the EKS Pod Identity Agent runs on each node and serves credentials to Pods. The ServiceAccount needs no annotation.
Set it up
First, install the agent as an EKS add-on.
aws eks create-addon \
--cluster-name my-cluster \
--addon-name eks-pod-identity-agentNext, create a role whose trust policy names the EKS service principal. The policy has no OIDC provider, subject, or audience condition.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "pods.eks.amazonaws.com"
},
"Action": [
"sts:AssumeRole",
"sts:TagSession"
]
}
]
}Then associate the role with the ServiceAccount.
aws eks create-pod-identity-association \
--cluster-name my-cluster \
--namespace demo \
--service-account app-reader \
--role-arn arn:aws:iam::111122223333:role/app-reader-roleScoping now happens in the association. Only Pods that use the demo/app-reader ServiceAccount in that cluster receive the role. Because the trust policy is the same for every cluster, you can reuse one role across clusters. The IAM permissions policy can also use the session tags that EKS adds, such as kubernetes-namespace and kubernetes-service-account.
What the Pod sees
When a Pod starts, EKS injects two environment variables: AWS_CONTAINER_CREDENTIALS_FULL_URI and AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE. The URI points to a link-local address served by the agent. A current AWS SDK finds these variables through its default container credential provider, so application code does not change.
Comparing the two
| Aspect | IRSA | Pod Identity |
|---|---|---|
| Mapping lives in | ServiceAccount annotation and role trust policy | EKS association |
| OIDC provider per cluster | Required | Not required |
| Trust policy | Cluster-specific subject and audience | One generic policy |
| Extra component | Webhook (managed by EKS) | Agent add-on on each node |
| Works on Fargate | Yes | No |
Common errors
- Old SDK. An SDK without container credential support ignores the injected variables and falls back to the node role. Upgrade the SDK.
- Missing
sts:TagSession. The association fails to produce credentials if the trust policy omits it. - Pods not restarted. Credentials are injected at Pod creation. Restart existing Pods after you create or change an association.
- Agent not running. Check that the DaemonSet is healthy on the node that hosts the Pod.
Exercise
You move a workload from IRSA to Pod Identity. Which two changes do you make to the role's trust policy and the ServiceAccount?
Show answer
Change the trust policy's principal to the service principal pods.eks.amazonaws.com, allowing sts:AssumeRole and sts:TagSession, and remove the OIDC provider conditions. Remove the eks.amazonaws.com/role-arn annotation from the ServiceAccount, because a Pod Identity association now makes the link. Then restart the Pods.