Sub topic 5
Choosing Where Pods Run
This chapter assumes you can create an EKS cluster with eksctl and that you know the basics of EC2 instances, Auto Scaling groups, and Kubernetes scheduling. It covers the three places an EKS pod can run and how to choose between them.
The Three Compute Options
The control plane is managed by AWS. Your pods still need compute, and EKS offers three kinds:
- Managed node groups are EC2 instances in an Auto Scaling group that EKS creates and updates for you.
- AWS Fargate runs each pod in its own isolated environment. You manage no nodes.
- Self-managed nodes are EC2 instances you launch and register yourself.
You can mix them in one cluster.
Managed Node Groups
A managed node group uses an EKS-optimized AMI and joins its nodes to the cluster automatically. When you update the group's AMI or Kubernetes version, EKS launches new nodes, cordons and drains the old ones, and respects Pod Disruption Budgets. You still pay for the EC2 instances and still choose the instance type and size.
This is the right default for most workloads. It supports On-Demand and Spot capacity, Graviton (Arm) instances, and custom launch templates.
Fargate
With Fargate, you create a Fargate profile that names a namespace and, optionally, labels. Any pod matching a selector is scheduled onto Fargate. Each pod gets its own sized compute, and you pay for the vCPU and memory the pod requests.
Fargate has limits you should know before choosing it:
- It does not support DaemonSets, privileged containers, or GPUs.
- Pods cannot use EBS volumes. EFS is supported.
- Pods run only in private subnets.
- Pods start more slowly than on a warm node.
Self-Managed Nodes
Self-managed nodes give you full control of the AMI, the bootstrap script, and the update process. Use them when you need a custom OS image, Windows nodes with special setup, or settings that managed node groups do not expose. The cost is operational work. You must roll out new AMIs and drain nodes yourself.
Comparing the Options
| Aspect | Managed node group | Fargate | Self-managed |
|---|---|---|---|
| Node patching | EKS orchestrates updates | AWS handles it | You |
| Billing | Per EC2 instance | Per pod vCPU and memory | Per EC2 instance |
| DaemonSets | Yes | No | Yes |
| GPUs | Yes | No | Yes |
| Custom AMI | Via launch template | No | Full control |
Combining Them in One Config
This eksctl config defines a managed node group, a self-managed node group, and a Fargate profile for the batch namespace:
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: demo
region: us-east-1
managedNodeGroups:
- name: ng-1
instanceType: m5.large
desiredCapacity: 2
minSize: 1
maxSize: 4
nodeGroups:
- name: self-1
instanceType: m5.large
desiredCapacity: 1
fargateProfiles:
- name: fp-batch
selectors:
- namespace: batchApply it with eksctl create cluster -f cluster.yaml. Then run kubectl get nodes. Fargate pods appear as nodes whose names start with fargate-.
Common Errors
- Pod stuck in Pending on Fargate. The pod's namespace or labels do not match any profile selector. Selectors are checked when the pod is created, so recreate the pod after you add a profile.
- CoreDNS Pending in a Fargate-only cluster. CoreDNS carries an annotation that targets EC2. It must be patched to run on Fargate.
- Node group will not scale. Check that
maxSizeis abovedesiredCapacityand that the subnets have free IP addresses.
Exercise
A team wants to run a log-collecting DaemonSet on every node and also run a small batch job with no node management. Which compute options fit each?
Show answer
The DaemonSet needs nodes, so use a managed node group, because Fargate does not support DaemonSets. The batch job can run on Fargate through a profile that selects its namespace. The DaemonSet will not run on the Fargate pods, so logging for those pods needs another approach.