IRSA¶
AWS binds a Kubernetes service account to an IAM role with a pair: a trust policy on the role, and a role-ARN annotation on the service account. The bundle renders both, already filled in.
The cluster side¶
apiVersion: v1
kind: ServiceAccount
metadata:
name: xratud
namespace: dp-eu-west1
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::<aws-account-id>:role/dp-eu-west1-runtime
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: builder
namespace: xratu-build-bootstrap
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::<aws-account-id>:role/dp-eu-west1-build
The ARN is built from account_id and the role name derived from dp_install,
so it is known at render time and requires no editing.
The cloud side¶
condition {
test = "StringEquals"
variable = "oidc.eks.<region>.amazonaws.com/id/<cluster-oidc-id>:sub"
values = ["system:serviceaccount:dp-eu-west1:xratud"]
}
How the two meet¶
flowchart LR
KSA["KSA xratud<br/>namespace dp-eu-west1"] -->|"role-arn annotation"| ROLE["IAM role<br/>dp-eu-west1-runtime"]
ROLE -->|"trust policy pins<br/>system:serviceaccount:dp-eu-west1:xratud"| KSA
ROLE --> ECR["ECR"]
ROLE --> S3["S3 bucket"]
Both halves name the same namespace and service account, which is why they are generated together from one spec. See One bundle, two layers.
Prerequisites on the cluster¶
The EKS cluster needs an IAM OIDC provider associated with it, and the pod identity webhook that EKS runs by default injects the token and environment variables. The bundle renders the role and the annotation; associating the provider is yours, once per cluster.
Verifying¶
The annotation:
The trust policy:
That the pod actually assumed it:
A pod with no AWS_ROLE_ARN in its environment means the annotation did not
reach the service account, or the webhook did not act on it.