IAM & IRSA
IAM & IRSA
IAM & IRSA
IAM Roles for Service Accounts (IRSA) allows Kubernetes service accounts to assume AWS IAM roles, enabling secure access to AWS services without storing credentials in the cluster.
This guide covers setting up IRSA for:
The Cluster Autoscaler needs permissions to modify Auto Scaling Groups.
Create a policy document:
Create the policy:
Note the policy ARN from the output.
Using eksctl:
Replace YOUR_ACCOUNT_ID with your AWS account ID.
Look for the annotation:
Configure the Cluster Autoscaler to use this service account:
Required for shared file storage (model caching).
Download the policy:
Create the policy:
Update the deployment to use the service account:
Required for block storage (PersistentVolumes).
The policy is available from AWS:
List all service accounts with IAM role annotations:
Create a test pod:
Apply and exec:
Should show the assumed role ARN.
Check service account annotation:
Should show:
Verify IAM policy:
Check trust relationship:
Should include trust policy for OIDC provider.
Verify OIDC provider exists:
Re-associate if needed:
Grant only the minimum permissions required for each service account.
Review and audit IAM policies regularly.
Create separate IAM roles for each service account rather than sharing roles.
This improves security and auditability.
Monitor IAM role usage via CloudTrail:
Tag IAM roles and policies for easier management:
Here’s a complete script to set up all IRSA roles:
Make executable and run: