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:cluster-autoscaler-policy.json
Create Service Account with IAM Role
Using eksctl:YOUR_ACCOUNT_ID with your AWS account ID.
Verify Service Account
Update Helm Values
Configure the Cluster Autoscaler to use this service account:values.yaml
EFS CSI Driver IRSA
Required for shared file storage (model caching).Create IAM Policy
Download the policy:Create Service Account with IAM Role
Install EFS CSI Driver
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:test-pod.yaml
Troubleshooting
Role Not Assumed
Check service account annotation:Permission Denied
Verify IAM policy:OIDC Provider Issues
Verify OIDC provider exists:Best Practices
Principle of Least Privilege
Principle of Least Privilege
Grant only the minimum permissions required for each service account.Review and audit IAM policies regularly.
Use Separate Roles
Use Separate Roles
Create separate IAM roles for each service account rather than sharing roles.This improves security and auditability.
Enable CloudTrail
Enable CloudTrail
Monitor IAM role usage via CloudTrail:
Tag Resources
Tag Resources
Tag IAM roles and policies for easier management:
Complete Example
Here’s a complete script to set up all IRSA roles:setup-irsa.sh

