IAM & IRSA
IAM & IRSA
Overview
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:
- Cluster Autoscaler
- EFS CSI Driver
- EBS CSI Driver
Prerequisites
Cluster Autoscaler IRSA
The Cluster Autoscaler needs permissions to modify Auto Scaling Groups.
Create IAM Policy
Create a policy document:
Create the policy:
Note the policy ARN from the output.
Create Service Account with IAM Role
Using eksctl:
Replace YOUR_ACCOUNT_ID with your AWS account ID.
Verify Service Account
Look for the annotation:
Update Helm Values
Configure the Cluster Autoscaler to use this service account:
EFS CSI Driver IRSA
Required for shared file storage (model caching).
Create IAM Policy
Download the policy:
Create the policy:
Create Service Account with IAM Role
Install EFS CSI Driver
Update the deployment to use the service account:
Verify
EBS CSI Driver IRSA
Required for block storage (PersistentVolumes).
Create IAM Policy
The policy is available from AWS:
Create Service Account with IAM Role
Install EBS CSI Driver Addon
Verify IRSA Configuration
Check Service Accounts
List all service accounts with IAM role annotations:
Test IAM Role Assumption
Create a test pod:
Apply and exec:
Should show the assumed role ARN.
Troubleshooting
Role Not Assumed
Check service account annotation:
Should show:
Permission Denied
Verify IAM policy:
Check trust relationship:
Should include trust policy for OIDC provider.
OIDC Provider Issues
Verify OIDC provider exists:
Re-associate if needed:
Best Practices
Principle of Least Privilege
Grant only the minimum permissions required for each service account.
Review and audit IAM policies regularly.
Use Separate Roles
Create separate IAM roles for each service account rather than sharing roles.
This improves security and auditability.
Enable CloudTrail
Monitor IAM role usage via CloudTrail:
Tag Resources
Tag IAM roles and policies for easier management:
Complete Example
Here’s a complete script to set up all IRSA roles:
Make executable and run:

