AWS Certified Developer – Associate
EKS Fargate profiles and EKS Pod Identity explained (DVA-C03)
The Amazon EKS User Guide says a Pod runs on Fargate only if it matches a selector in a Fargate profile when it is scheduled. Fargate sizes the Pod from its container requests plus 256 MB. EKS Pod Identity maps an IAM role to a Kubernetes service account, but it does not support Pods on Fargate.
How does a Fargate profile choose Pods?
The DVA-C03 exam guide lists deploying containerized applications with container orchestration services, with Amazon EKS manifests and AWS Fargate among the examples, as content added to Task 3.3.
A cluster needs at least one Fargate profile before Pods can be scheduled on Fargate. A profile has up to five selectors. Each selector must name a namespace and can also list labels. A Pod that matches any selector is scheduled on Fargate. A namespace selector without labels takes every Pod in that namespace. Kubernetes affinity rules do not apply to Fargate Pods.
A Pod that matches no profile might be stuck as Pending. Once a matching profile exists, deleting the pending Pods lets them be rescheduled onto Fargate.
A profile also sets a Pod execution role and subnets. The execution role lets the Fargate infrastructure register with the cluster and pull images from Amazon ECR. Only private subnets are accepted. Fargate profiles cannot be changed: create a new profile, then delete the original. Deleting a profile stops its Pods and puts them into a pending state.
How does Fargate size and bill a Pod?
Fargate adds up the requests of the long-running containers, compares that with the largest init container request and takes the larger value. It then adds 256 MB of memory for kubelet, kube-proxy and containerd, and rounds up to the closest available combination. With no requests the Pod gets the smallest combination, 0.25 vCPU and 0.5 GB.
The 1 vCPU row allows 2 GB to 8 GB. The 2 vCPU row allows 4 GB to 16 GB. Example: a request of 1 vCPU and 8 GB becomes 8 GB plus 256 MB, which no 1 vCPU combination holds, so Fargate provisions 2 vCPU and 9 GB. A request of 1 vCPU and 7936 MiB lands on 1 vCPU and 8 GB.
The CapacityProvisioned annotation on the Pod shows the enforced capacity, and it determines the cost of the Pod. The node size that kubectl get nodes reports is not related to it. Fargate runs one Pod per node, and CPU and memory requests must equal the limits for every container.
DaemonSets are not supported on Fargate. A daemon has to run as a sidecar container in the Pods.
EKS Pod Identity vs IAM roles for service accounts
EKS Pod Identity gives applications credentials in a way similar to an EC2 instance profile. An association maps one IAM role to a service account in a namespace in a cluster. The role's trust policy names the pods.eks.amazonaws.com service principal. The EKS Pod Identity Agent runs as a DaemonSet on the nodes and issues the credentials to the AWS SDKs in Pods on the same node. Only Pods that use that service account get the role's permissions.
AWS describes EKS Pod Identity as simpler than IAM roles for service accounts (IRSA) because it does not use OIDC identity providers. The same role can be used in several clusters without editing its trust policy.
EKS Pod Identity works only for Pods on Linux Amazon EC2 instances. Pods on Fargate are not supported, and neither are Pods on Windows EC2 instances. The instance metadata service is not available to Fargate Pods either. For Fargate Pods that need IAM credentials, AWS says to use IAM roles for service accounts.
Where the exam catches people
- Believing a label or a node affinity rule on the Pod puts it on Fargate: the Pod must match a selector in a Fargate profile, and each selector names a namespace.
- Believing an existing Fargate profile can be edited to add a namespace or change subnets: profiles cannot be changed. Create a new profile.
- Believing a container request of 1 vCPU and 8 GB is billed as 1 vCPU and 8 GB: the extra 256 MB pushes it to 2 vCPU and 9 GB.
- Believing EKS Pod Identity works for Pods on Fargate: it supports only Linux EC2 nodes. Fargate Pods use IAM roles for service accounts.
- Believing application permissions belong on the node role or the Pod execution role: an association or IRSA scopes a role to one service account.