Learning objectives
- Explain that Fargate runs pods, not EC2 instances.
- Select only labeled worker pods in one namespace.
- Keep platform, DaemonSet, privileged, GPU, and EBS-backed workloads on EC2.
The selector is the placement boundary
A profile is not a general serverless switch. Both namespace and label must match when the pod is scheduled.
What fits Fargate
| Workload need | Fargate? | Course placement |
|---|---|---|
| Stateless queue worker with normal pod networking | Yes | workers namespace plus compute=fargate. |
| Envoy Gateway, Argo CD, monitoring agents | No for this design | Dedicated EC2 system group. |
| DaemonSets | No | EC2; Fargate does not support DaemonSets. |
| Privileged containers, host networking, or HostPort | No | Reviewed EC2 group if the security design permits them. |
| GPUs | No | GPU-capable EC2 node group. |
| EBS-backed pods, including Cassandra | No | Dedicated EC2 group; EBS volumes cannot mount to Fargate pods. |
Lab: inspect the selector
# The same mocked test runs with either CLI.
terraform -chdir=learn-terraform/capstone/infra/modules/eks test -filter=tests/eks.tftest.hcl
tofu -chdir=learn-terraform/capstone/infra/modules/eks test -filter=tests/eks.tftest.hcl
# Review the two selector dimensions.
rg 'fargate_namespace|fargate_labels|selector' learn-terraform/capstone/infra/modules/eks learn-terraform/capstone/infra/environmentsThe test rejects a namespace-only profile. A broad selector can silently move future pods to Fargate, so the label is part of the contract.
Plan and runtime behavior
- The Fargate pod execution role lets EKS launch the pod and pull images. It is not the application workload role.
- EKS Pod Identity does not support Fargate. A Fargate application that calls SQS or another AWS API uses IAM roles for service accounts (IRSA); its containers cannot assume the pod execution role.
- This EKS Terraform state owns the IAM OIDC provider lifecycle and exports its ARN. Task 10's data Terraform state owns the Fargate worker IAM role because it knows the exact SQS permissions. Task 10's GitOps Helm chart owns the service-account annotation because it knows the exact Kubernetes service account.
- Fargate profiles use private subnets only. Those subnets need NAT or reviewed VPC endpoints.
- Changing selectors or subnets replaces the profile. Existing pods do not automatically move; rescheduling evaluates profiles again.
- Fargate services behind load balancers use IP targets. The later Envoy Gateway stays on EC2 system nodes.
- Mixed compute keeps one control plane while choosing the smallest suitable runtime per pod class.
Failure drill
default or remove the label merely to make scheduling succeed.Verify boundaries
- Exactly one profile selects
workersandcompute=fargate. - Its subnet set equals the foundation private subnet set.
- System and Cassandra remain On-Demand EC2.
- No Kubernetes or Helm provider appears in the EKS Terraform root.
Cleanup
The mocked test leaves no AWS resources. After a future apply, remove or relabel the owning Deployment before deleting its profile; otherwise replacement pods can remain Pending.
Quick check
Does Fargate create EC2 instances in your account?
No. EKS schedules matching pods onto AWS-managed Fargate compute; you do not manage an EC2 group for those pods.
Can the EBS CSI controller run on Fargate?
The controller can, but the EBS CSI node DaemonSet must run on EC2, and EBS volumes cannot mount to Fargate pods.
Recap and next
Fargate is a narrow pod runtime for labeled stateless workers. EC2 remains the home for Envoy, platform agents, DaemonSets, GPUs, privileged networking, and EBS-backed state.
Next in Phase 4: add autoscaling ownership, EBS CSI and snapshots, then Envoy Gateway behind a private NLB.
Source notes
- AWS: EKS Fargate considerations
- AWS: define which pods use Fargate
- AWS: Fargate pod configuration
- HashiCorp AWS provider 6.60: EKS Fargate profile resource
- AWS: EKS Pod Identity agent
- AWS: Fargate pod execution role and IRSA boundary
- AWS: EKS Pod Identity restrictions
- HashiCorp AWS provider 6.60: IAM OIDC provider resource
- Terraform: explicit dependencies
- OpenTofu: explicit dependencies