Certopolis

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.

Written from these sources

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. An Amazon EKS cluster runs all of its workloads on AWS Fargate and has one Fargate profile with a selector for the prod namespace. A developer deploys a new application into the staging namespace, and its Pods stay in the Pending state. The staging Pods must run on Fargate. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Testing and Deployment building.

    Not that one: D is right. In the game your Testing and Deployment building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Because profiles cannot be edited, the fix is a new profile that selects staging; deleting the Pending Pods lets them be recreated and matched to it.

    Written from docs.aws.amazon.com/eks/latest/userguide/fargate-profile.html

  2. An application runs in Pods on AWS Fargate in an Amazon EKS cluster. Each Pod has one container with a CPU request and limit of 1 vCPU and a memory request and limit of 9216 MiB, and the CapacityProvisioned annotation shows 2 vCPU and 10 GB. The company wants each Pod billed at a 1 vCPU configuration, with the container given as much memory as that allows. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Testing and Deployment building.

    Not that one: C is right. In the game your Testing and Deployment building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    The largest 1 vCPU combination is 8 GB, so the container can request at most 8 GB minus 256 MB, which is 7936 MiB. That lands exactly on 1 vCPU and 8 GB, which the CapacityProvisioned annotation will then show.

    Written from docs.aws.amazon.com/eks/latest/userguide/fargate-pod-configuration.html

  3. Applications in Pods on an Amazon EKS cluster that runs on Amazon EC2 nodes must read objects from an Amazon S3 bucket. Each application must receive only its own permissions, and the cluster administrators do not want to create an IAM OpenID Connect (OIDC) identity provider. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Testing and Deployment building.

    Not that one: B is right. In the game your Testing and Deployment building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Only those Pods get the role, which meets the least-privilege requirement, and unlike IAM roles for service accounts it needs no OIDC identity provider.

    Written from docs.aws.amazon.com/eks/latest/userguide/pod-identities.html

Ask for something