EKS
Irsaandpip

πŸ” Part 1 β€” IRSA vs EKS Pod Identity (Clear Comparison)

First β€” say this in interview:

Both IRSA and Pod Identity solve the same problem: giving pods AWS permissions without using node IAM role or static keys β€” but they use different mechanisms.

That’s a strong start.


βœ… What Problem Both Solve

Without IRSA/Pod Identity:

Pod β†’ uses node IAM role ➑ every pod gets same permissions ➑ huge blast radius risk ❌

Both solutions give: βœ… pod-level IAM βœ… least privilege βœ… no static credentials βœ… auditable access


πŸ₯‡ IRSA β€” IAM Roles for Service Accounts

IRSA = OIDC + STS + ServiceAccount token method

Flow:

ServiceAccount β†’ OIDC token β†’ STS AssumeRoleWithWebIdentity β†’ temp creds


βœ… IRSA Characteristics

  • Uses Kubernetes OIDC issuer
  • Uses projected service account token
  • Pod calls STS directly
  • No agent required
  • Mature & widely used
  • Works everywhere EKS supports OIDC
  • Fully AWS-native method

πŸ†• EKS Pod Identity (Newer Model)

Pod Identity = agent-based credential vending

Flow:

Pod β†’ Pod Identity Agent β†’ EKS control plane β†’ STS β†’ creds


βœ… Pod Identity Characteristics

  • Uses node agent (DaemonSet)
  • Does not require OIDC provider setup
  • Simpler config
  • Central credential broker
  • AWS-managed control plane integration
  • Less token plumbing visible

βš–οΈ IRSA vs Pod Identity β€” Interview Comparison Table (in words)

Say this verbally:

IRSA

  • OIDC based
  • no agent
  • pod talks to STS
  • more setup
  • very mature
  • fully transparent flow

Pod Identity

  • agent based
  • simpler setup
  • control plane mediated
  • newer feature
  • easier for teams
  • less moving parts for users

🧠 Interview Positioning Answer

If asked β€œwhich would you choose?”

Say:

Today I default to IRSA because it’s mature and widely adopted, but for new clusters I evaluate Pod Identity for simpler operational setup β€” especially when platform teams want centralized credential brokering.

That sounds balanced and senior.


πŸͺͺ Part 2 β€” What is OIDC (In EKS Context)

Don’t give textbook OAuth speech. Interviewers want EKS-specific OIDC.


βœ… What is OIDC here?

OIDC = identity token issuer standard using signed JWT tokens.

In EKS:

Kubernetes API server acts as an OIDC issuer for service accounts.

Each cluster exposes:

https://oidc.eks.<region>.amazonaws.com/id/<cluster-id>

This is a public identity provider endpoint.


βœ… What It Issues

Kubernetes issues signed JWT tokens for service accounts.

Token contains:

  • service account name
  • namespace
  • audience
  • expiry
  • issuer

These tokens are cryptographically signed.


βœ… Why AWS Trusts It

You register this OIDC issuer with IAM as an OIDC identity provider.

IAM then trusts tokens signed by that issuer.

That trust enables STS web identity role assumption.


πŸ” Part 3 β€” What is STS AssumeRoleWithWebIdentity

This is the core of IRSA. Many candidates fail here.


βœ… Definition (Interview Style)

AssumeRoleWithWebIdentity is an STS API that allows a role to be assumed using an external OIDC/JWT token instead of AWS credentials.

No AWS keys required.


βœ… IRSA Flow β€” Step by Step (Say This in Interview)

1️⃣ Pod runs with ServiceAccount 2️⃣ Kubernetes injects OIDC JWT token file 3️⃣ Pod calls STS AssumeRoleWithWebIdentity 4️⃣ STS validates token against IAM OIDC provider 5️⃣ Trust policy matches subject 6️⃣ STS returns temporary AWS credentials 7️⃣ SDK uses creds automatically

That’s the full chain.


πŸ“œ Trust Policy Example Logic (Conceptual)

Role trust policy says:

β€œAllow assume role if:

  • token issuer = this cluster OIDC
  • subject = this service account
  • namespace = this namespace”

This is how least privilege is enforced.


πŸ” Why This Is Secure


βœ… Security Properties

  • short-lived tokens
  • cryptographically signed
  • scoped to service account
  • no stored secrets
  • no node-role sharing
  • fully auditable in CloudTrail

⚠️ Common Interview Trap β€” Node Role vs IRSA

If interviewer asks:

β€œWhy not just use node IAM role?”

Answer:

Because that gives every pod the same AWS permissions. A single pod compromise becomes full node privilege escalation. IRSA/Pod Identity reduces blast radius to pod level.

Strong answer.


🧨 Real Failure Modes (Bonus Interview Points)

Mention these = senior signal:

  • OIDC provider not created β†’ IRSA fails
  • wrong audience field β†’ STS reject
  • trust policy subject mismatch
  • token expired β†’ auth errors
  • clock skew issues
  • service account annotation wrong

🧠 One-Shot Senior Interview Summary Answer

If they ask open-ended:

β€œExplain IRSA, OIDC, and web identity STS together.”

Say:

In EKS, IRSA uses the cluster’s OIDC issuer to generate signed service account tokens. IAM trusts that OIDC provider. Pods present the token to STS using AssumeRoleWithWebIdentity, which validates the token and issues temporary credentials for the mapped IAM role. That gives pod-level least-privilege AWS access without static keys or node-role overexposure.




βœ… Scenario 1 β€” Access S3 from Pod using IRSA (IAM Roles for Service Accounts)

IRSA works by:

  • Linking Kubernetes ServiceAccount β†’ IAM Role
  • Using OIDC federation
  • Pod gets AWS creds via projected token + STS AssumeRoleWithWebIdentity

Step 0 β€” Preconditions

  • EKS cluster exists
  • kubectl configured
  • AWS CLI configured
  • You have cluster admin access

Step 1 β€” Enable OIDC provider for EKS cluster

Check if exists:

aws eks describe-cluster --name <cluster-name> \
  --query "cluster.identity.oidc.issuer" --output text

Associate OIDC provider (if not already):

eksctl utils associate-iam-oidc-provider \
  --cluster <cluster-name> \
  --approve

Step 2 β€” Create IAM policy for S3 access

Example: read access to one bucket

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:GetObject","s3:ListBucket"],
      "Resource": [
        "arn:aws:s3:::my-app-bucket",
        "arn:aws:s3:::my-app-bucket/*"
      ]
    }
  ]
}

Create it:

aws iam create-policy \
  --policy-name eks-s3-read \
  --policy-document file://policy.json

Step 3 β€” Create IAM role for ServiceAccount

Using eksctl (simplest):

eksctl create iamserviceaccount \
  --name s3-sa \
  --namespace default \
  --cluster <cluster-name> \
  --attach-policy-arn arn:aws:iam::<acct>:policy/eks-s3-read \
  --approve

This does:

  • Creates IAM role
  • Adds trust policy with OIDC
  • Annotates ServiceAccount

Step 4 β€” Verify ServiceAccount annotation

kubectl get sa s3-sa -o yaml

You should see:

annotations:
  eks.amazonaws.com/role-arn: arn:aws:iam::<acct>:role/...

Step 5 β€” Use SA in Pod spec

apiVersion: v1
kind: Pod
metadata:
  name: s3-test
spec:
  serviceAccountName: s3-sa
  containers:
  - name: app
    image: amazon/aws-cli
    command: ["sleep","3600"]

Step 6 β€” Test inside pod

kubectl exec -it s3-test -- sh
 
aws s3 ls s3://my-app-bucket

Done. That’s IRSA working.


βœ… Scenario 2 β€” Access S3 using EKS Pod Identity (Newer Method)

Blunt truth: This is operationally cleaner than IRSA. No OIDC fiddling. No SA annotations. AWS manages the credential injection via a Pod Identity Agent.

Pod Identity works by:

  • EKS control plane + Pod Identity Agent
  • IAM role bound directly to k8s ServiceAccount
  • Uses EKS credential service instead of STS web identity token

Step 0 β€” Preconditions

  • EKS version supports Pod Identity
  • AWS CLI updated
  • Add-on install allowed

Step 1 β€” Install Pod Identity Agent addon

aws eks create-addon \
  --cluster-name <cluster-name> \
  --addon-name eks-pod-identity-agent

Verify:

kubectl get pods -n kube-system | grep pod-identity

Step 2 β€” Create IAM role for pod

Trust policy is different from IRSA β€” uses pods.eks.amazonaws.com

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "pods.eks.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}

Create role:

aws iam create-role \
  --role-name eks-pod-s3-role \
  --assume-role-policy-document file://trust.json

Attach S3 policy:

aws iam attach-role-policy \
  --role-name eks-pod-s3-role \
  --policy-arn arn:aws:iam::<acct>:policy/eks-s3-read

Step 3 β€” Create Pod Identity Association

This is the key step (no annotation needed):

aws eks create-pod-identity-association \
  --cluster-name <cluster-name> \
  --namespace default \
  --service-account s3-sa \
  --role-arn arn:aws:iam::<acct>:role/eks-pod-s3-role

Step 4 β€” Create ServiceAccount (plain)

apiVersion: v1
kind: ServiceAccount
metadata:
  name: s3-sa
  namespace: default

No annotations. Nothing fancy.


Step 5 β€” Pod spec same as before

spec:
  serviceAccountName: s3-sa

Step 6 β€” Test

kubectl exec -it s3-test -- aws s3 ls

Works.


βš”οΈ IRSA vs Pod Identity β€” Real Differences (No Marketing Talk)

πŸ”Ή Setup Complexity

IRSA

  • Needs OIDC provider
  • Needs trust policy with condition keys
  • Needs SA annotations
  • More moving parts

Pod Identity

  • No OIDC
  • No annotations
  • Single AWS association command
  • Cleaner

Winner β†’ Pod Identity


πŸ”Ή Maturity

IRSA

  • Production proven for years
  • Used everywhere
  • Tooling ecosystem supports it

Pod Identity

  • Newer
  • Still rolling into org standards
  • Some enterprises not fully migrated yet

Winner β†’ IRSA (today)


πŸ”Ή Security Model

Both are strong if configured correctly.

But mistakes happen more with IRSA because:

  • Wrong trust conditions
  • OIDC misbinding
  • Copy-paste policies

Pod Identity removes many human error points.

Winner β†’ Pod Identity


πŸ”Ή Multi-cluster / Cross-account

IRSA:

  • Easier to design complex federation

Pod Identity:

  • Currently more cluster-local oriented

Winner β†’ IRSA


πŸ”Ή Operational Burden

IRSA:

  • More YAML + IAM glue
  • More debugging pain

Pod Identity:

  • Less cognitive load
  • Easier onboarding for teams

Winner β†’ Pod Identity



πŸ’¬ Need a Quick Summary?

Hey! Don't have time to read everything? I get it. 😊
Click below and I'll give you the main points and what matters most on this page.
Takes about 5 seconds β€’ Uses Perplexity AI