
AWS: EKS Pod Identity feature , a better approach compared to IRSA
AWS: EKS Pod Identity feature , a better approach compared to IRSA
- Create a cluster with
eksctl
and OIDC provider setup enabled. - Create an IAM role defining access to the target AWS services, for example S3, and annotate a service account with said IAM role.
- Configure your pods by using the service account created in the previous step and assume the IAM role.
- Install Amazon EKS Pod Identity Agent add-on using the Amazon EKS console or AWS Command Line Interface (AWS CLI).
- Create an IAM Role, and in the Trust Policy of which we now use
Principal: pods.eks.amazonaws.com
as the service principal - Map the role directly to the desired ServiceAccount in the Amazon EKS console, APIs, or AWS CLI.
- Install Amazon EKS Pod Identity Agent add-on from list of given add-ons
Principal: pods.eks.amazonaws.com
as the service principal1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
apiVersion: v1
kind: Namespace
metadata:
name: dev-ns
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: dev-sa
namespace: dev-ns
---
apiVersion: v1
kind: Pod
metadata:
name: dev-pod
namespace: dev-ns
spec:
containers:
- name: aws-cli
image: amazon/aws-cli:latest
command: ['sleep', '36000']
restartPolicy: Never
serviceAccountName: dev-sa
1
2
3
4
$ kubectl apply -f pod.yaml
namespace/dev-ns created
serviceaccount/dev-sa created
pod/dev-pod created
1
2
3
4
kubectl -n dev-ns exec -it dev-pod -- /bin/bash
bash-4.2# aws s3 ls
2024-01-01 15:29:34 cloudformation-deployment-123123
2024-01-01 16:40:56 terraform-deployment-123123