Spot Instances on EKS
Spot Instances are spare EC2 capacity sold at a discount of up to 90%. The catch is one sentence long: AWS can take the instance back with two minutes’ notice. Kubernetes is well suited to that contract, because rescheduling pods is what it does all day — provided the workloads are built to move.
The interruption contract
| Signal | Lead time | Meaning |
|---|---|---|
| Rebalance recommendation | Minutes, sometimes none | The instance is at elevated risk; a good moment to replace it proactively |
| Spot interruption notice | 2 minutes | The instance will be reclaimed |
Spot has no bidding any more. The price moves slowly with long-term supply and demand, and interruptions happen when AWS needs the capacity back, not because someone outbid you. See EC2 pricing models.
Diversify, or it will not work
Each combination of instance type and Availability Zone is a separate capacity pool with its own spare capacity. Asking for one type in one zone means one pool; when it empties, you have nothing. Asking for ten types across three zones gives thirty pools.
- Allow many instance types of the same size (required for Cluster Autoscaler):
m5.xlarge,m5a.xlarge,m6i.xlarge,m6a.xlarge,m7i.xlarge,m5d.xlarge. - Include older generations and AMD or Graviton variants.
- Use every zone your subnets cover.
The allocation strategy does the rest. Price-capacity-optimized picks pools that are both cheap and deep, which lowers the interruption rate compared with choosing the lowest price.
With managed node groups
managedNodeGroups:
- name: spot-xlarge
capacityType: SPOT
instanceTypes:
["m5.xlarge", "m5a.xlarge", "m6i.xlarge", "m6a.xlarge", "m7i.xlarge"]
minSize: 0
maxSize: 30
labels: { lifecycle: spot }
taints:
- { key: spot, value: "true", effect: NoSchedule }A Spot managed node group handles interruptions without extra software:
- It enables capacity rebalancing. On a rebalance recommendation, EKS launches a replacement, waits for it to join, then cordons and drains the at-risk node.
- On the two-minute notice, the node is drained immediately.
- Nodes are labelled
eks.amazonaws.com/capacityType: SPOT, which you can target with node selectors or affinity.
Self-managed groups get none of this; they need the AWS Node Termination Handler.
With Karpenter
Karpenter needs only karpenter.sh/capacity-type In [spot, on-demand] in a NodePool. It chooses from every instance type that satisfies the requirements, prefers Spot, falls back to On-Demand when Spot is unavailable, and uses the interruption queue to drain nodes on the two-minute notice. Because it is not limited to same-size types, it diversifies far better than node groups can.
Making workloads tolerate interruption
Two minutes is enough only if the application cooperates:
- More than one replica, spread out. Use topology spread constraints across zones and nodes so one reclaim never removes all replicas.
- A PodDisruptionBudget so proactive drains happen one pod at a time.
- Graceful shutdown within the window. Handle
SIGTERM, stop accepting work, finish in-flight requests. KeepterminationGracePeriodSecondscomfortably under 120 seconds. See signals. - Readiness probes that tell the truth, so replacement pods receive traffic only when ready — probes.
- Idempotent, checkpointed batch work. A Job that restarts from scratch after 50 minutes of a 60-minute run wastes the saving.
What belongs on Spot
| Good fit | Keep on On-Demand |
|---|---|
| Stateless web and API services with ≥ 2 replicas | Single-replica anything |
| CI runners, batch and data processing | Databases and quorum systems (etcd, Kafka, ZooKeeper) unless designed for it |
| Dev and test environments | Cluster-critical add-ons: CoreDNS, ingress controllers, the autoscaler itself |
| Horizontally scaled workers behind a queue | Jobs that cannot checkpoint and run for hours |
A common production shape is an On-Demand baseline, covered by Savings Plans, that carries critical add-ons and a minimum number of replicas, with everything above it on Spot. Enforce it with a taint on Spot nodes plus tolerations, or with a topology spread on the capacity-type label.
Measuring it
- The Spot Instance Advisor shows interruption frequency per instance type and region.
- The Spot placement score API estimates how likely a request for N instances is to succeed.
- Track node churn and pod restart counts after moving a workload; rising error rates during reclaims mean the shutdown path needs work, not that Spot is unsuitable.
Related
- EKS cost optimization
- EC2 cost optimization
- Chaos engineering — rehearse node loss before Spot does it for you
- Spot best practices for EKS
Across the wiki
- AKS Heterogeneous Node Pools — System vs User, Ephemeral OS Disks, and Azure Linux — node pools and spot capacity (Azure)
- GKE Heterogeneous Node Pools, Taints, Tolerations, and Accelerator Topologies — node pools and spot capacity (GCP)
- Azure Spot VMs & Scheduled Events Eviction Engineering — node pools and spot capacity (Azure)