How Karpenter assigns AMIs to nodes
When you create anEC2NodeClass, you must specify amiSelectorTerms. These terms determine which AMIs Karpenter can use when launching nodes. Karpenter always selects the newest compatible AMI from those matched by your terms.
Static vs dynamic selector terms
SomeamiSelectorTerm types always resolve to the same AMI (static), while others may resolve to different AMIs over time (dynamic).
| Type | Behavior | Example |
|---|---|---|
id | Static — always resolves to one specific AMI | id: ami-052c9ea013e6e3567 |
name (exact) | Static — resolves to the AMI with that exact name | name: al2023-ami-2023.3.20240219.0-kernel-6.1-x86_64 |
alias (versioned) | Static per K8s version — resolves to a pinned release matching the cluster control plane | alias: al2023@v20240807 |
alias (@latest) | Dynamic — resolves to the newest release of that AMI family | alias: al2023@latest |
name (wildcard) | Dynamic — resolves to whichever AMI matches at launch time | name: al2023-ami-* |
tags | Dynamic — resolves to whichever tagged AMI exists at launch time | tags: { env: prod } |
AMI families and aliases
Karpenter supports the following well-known AMI families, each with a corresponding alias:| AMI family | Alias prefix | Notes |
|---|---|---|
| Amazon Linux 2 | al2 | Legacy; consider migrating to AL2023 |
| Amazon Linux 2023 | al2023 | Recommended default |
| Bottlerocket | bottlerocket | Container-optimized, immutable OS |
| Windows Server 2019 | windows2019 | Windows workloads |
| Windows Server 2022 | windows2022 | Windows workloads |
| Windows Server 2025 | windows2025 | Windows workloads |
<family>@<version> or <family>@latest
Versioned aliases (e.g.
al2023@v20240807) pin the AMI release but still account for the Kubernetes control plane version of your cluster. If you upgrade your EKS cluster’s Kubernetes version, Karpenter will drift nodes to a new AMI that matches both the pinned release version and the new K8s version. By contrast, id and name terms are fully static regardless of K8s version.When node replacement occurs
Whenever a node is replaced, the replacement node uses the newest AMI matched by youramiSelectorTerms. Replacement is triggered by:
- Expiration — node reaches its configured TTL and is automatically replaced
- Consolidation — Karpenter finds a cheaper node configuration for the same workloads
- Drift — the node’s actual state no longer matches the desired state in
NodePoolorEC2NodeClass - Interruption — involuntary disruption (e.g. Spot interruption, EC2 health events)
amiSelectorTerms changes — either from a manual update or from a dynamic term resolving to a new release.
Controlling AMI replacement
Karpenter gives you several tools to control the risk of rolling out new AMIs:- Pin AMIs — ensure only a tested AMI is used in production
- Test AMIs — validate new releases in lower environments before promoting
- Use disruption budgets — limit the pace and schedule of node replacements
Pinning AMIs
Pinning ensures Karpenter uses only a specific, tested AMI. There are several ways to express a pin:- Alias (versioned)
- Name (exact)
- ID
Pins to a specific AMI release. Karpenter still accounts for the cluster’s K8s version, so the actual AMI ID may change after a Kubernetes upgrade.
Testing AMIs
The safest approach is to validate new AMI releases in lower environments before promoting to production. Test cluster — use@latest to always run the most recent AMI:
EC2NodeClass. Karpenter will detect the change and drift existing nodes to the new AMI over time.
Using disruption budgets
Disruption budgets let you control the speed and schedule of node replacements, limiting blast radius if a new AMI causes problems.Node disruption budgets
Setdisruption.budgets in your NodePool spec:
nodes— maximum nodes to disrupt simultaneously (percentage or absolute count)schedule— cron expression for when this budget is active (uses crontab format)duration— how long the budget remains active afterschedulefiresreasons— restrict the budget to specific disruption types (Drifted,Expired,Underutilized)
Pod disruption budgets
Configure Pod Disruption Budgets for applications running on your cluster. Karpenter respects PDBs during graceful disruption — if replacing a node would violate a PDB, Karpenter will not replace that node. This is especially important during an AMI rollout: if a faulty AMI begins causing application failures, PDBs signal to Karpenter that nodes must stop being replaced, preventing the bad AMI from propagating cluster-wide.The drift mechanism
Drift is Karpenter’s reconciliation loop that detects when a node’s actual state no longer matches the desired state declared in yourNodePool or EC2NodeClass. For AMIs specifically:
- You update
amiSelectorTerms(e.g. change a version pin, or a dynamic term resolves to a new AMI) - Karpenter evaluates existing nodes against the new desired state
- Nodes whose AMI no longer matches are marked as drifted
- Karpenter replaces drifted nodes subject to your disruption budgets
@latest aliases, Karpenter also polls periodically for new AMI releases. A newly published AMI can trigger drift automatically without any manual change to your configuration.
Unlike Managed Node Groups (MNG), which never automatically upgrade AMIs when launching replacement nodes, Karpenter will use the newest matching AMI whenever a node is replaced. This means dynamic selector terms can introduce a new AMI into your cluster at any time a node is replaced — not just when drift is explicitly triggered.