Karpenter NodePool Patterns: Spot, Consolidation and Expiry
A Karpenter NodePool decides which nodes a cluster may launch, how aggressively idle capacity is removed, and when nodes are replaced on a schedule. This guide builds production NodePool patterns for Spot diversity, consolidation, disruption budgets and expiry, with the guardrails that keep cost cutting from turning into Pod churn during traffic peaks.
Introduction
A Karpenter NodePool is the policy object that tells Karpenter what nodes it may create for pending Pods and how it may disrupt nodes later. Requirements bound the instance shapes, disruption settings govern consolidation, and expiry forces node replacement on a cadence you choose.
The previous lesson, the Kubernetes HPA v2 tutorial, scaled Pods; this lesson, still in Module 11 on Kubernetes autoscaling, scales the nodes those Pods land on. The companion pillar, Karpenter vs Cluster Autoscaler, covers choosing the node autoscaler. This guide assumes Karpenter is installed and focuses on NodePool design that survives production traffic.
Consider an illustrative composite drawn from common production reviews, not a named incident. A team enables Karpenter with a single broad NodePool and default disruption settings. Node costs fall for two weeks. Then a marketing peak arrives, the HPA adds replicas, Karpenter launches Spot nodes, and consolidation starts moving Pods off half-empty nodes minutes later, during the peak. Latency wobbles, a batch pool loses work to a Spot interruption nobody wired alerts for, and the post-incident review finds three separate settings doing exactly what they were told to do.
The 5-minute takeaway
Requirements should stay broad, especially for Spot, because diversity is availability. Consolidation needs a quiet period and budgets that respect traffic hours. Expiry replaces nodes on your schedule instead of the cloud provider's. Every pool gets CPU and memory limits as a billing guardrail. PodDisruptionBudgets and termination grace periods decide whether disruption feels invisible or expensive.
1. Karpenter NodePool anatomy: template, disruption and limits
A Karpenter NodePool has three working parts: a node template describing nodes to launch, a disruption block governing voluntary node removal, and optional limits capping total capacity. The template references a NodeClass, on AWS an EC2NodeClass, which carries provider details such as AMIs, subnets and security groups.
Read the object top to bottom as three questions. What may launch: the template, its requirements and its NodeClass reference. What may be removed, and how fast: the disruption block with its policy, quiet period and budgets. How far may this go: limits on total CPU and memory across the pool. Most production surprises trace to one of these three answers being a default nobody chose.
Two placement details matter in the v1 API. expireAfter lives under spec.template.spec, not under disruption, and terminationGracePeriod sits beside it. Requirements live in the template too, while labels and taints for launched nodes sit under template metadata and template spec respectively. Copying v1alpha5 or v1beta1 examples into a v1 cluster produces objects that apply cleanly and behave differently than expected, so check the API version on every example you borrow.
The NodeClass split is deliberate. NodePools express scheduling policy that platform teams tune per workload; NodeClasses express cloud wiring that changes rarely and carries security weight, such as IAM roles and AMI selection. Keep NodeClasses few and reviewed like infrastructure code, and let NodePools vary. Mixing the two concerns into many near-identical pairs makes every change a two-object review.
2. Karpenter NodePool requirements: diversity is a feature
Karpenter NodePool requirements filter which instance types and zones Karpenter may pick, and broader requirements produce better outcomes, especially for Spot. Karpenter already filters by Pod requests and constraints; your requirements should express real boundaries such as architecture or capacity type, not a favourite instance family.
Every requirement narrows the menu Karpenter can price. Pin one instance type and Karpenter can only wait when that pool is dry or expensive. Allow several families across multiple zones and Karpenter picks the cheapest fit from deeper capacity, which on Spot also means lower interruption risk, because the price-capacity-optimized allocation strategy favours pools with more spare capacity. Diversity is not sloppiness; it is the mechanism that makes Spot boring.
Constrain by shape, not by SKU. Requirements on instance category, generation, CPU and memory ranges, and architecture express intent that survives new instance launches. A requirement such as instance CPU between 2 and 16 with memory per CPU in a sane band lets Karpenter rightsize nodes to pending Pods, including bin-packing several small Pods onto one node. Lists of exact instance types rot quickly and quietly block better shapes released later.
Architecture deserves an explicit decision. Allowing arm64 alongside amd64 usually cuts cost per unit of work, but only for images built multi-arch and dependencies that run on both. Gate arm64 behind a separate pool or a node selector until images prove themselves, because a Pod that cannot exec on ARM fails in ways that look like application bugs. The EKS vs GKE vs AKS production guide covers the platform context for these EKS-specific choices.
Zones are requirements too, through topology labels. Spread pools across the zones your workloads tolerate, and remember that zonal capacity dries up independently. A pool restricted to one zone for data-locality reasons is a legitimate choice with a visible cost: Spot availability and consolidation options shrink with it. Write that trade into the pool comment so the next engineer does not widen it casually.
3. Karpenter NodePool topology: a few shared pools, separated by taints
Karpenter NodePool topology works best as a small set of shared pools separated by purpose, commonly a system pool for add-ons, a web pool for stateless services, and a batch pool for interruption-tolerant work. Distinct taints keep workloads in their pools, and weight resolves overlaps deliberately.
The system pool runs cluster add-ons such as CoreDNS, ingress controllers and monitoring agents on on-demand capacity with a taint application Pods do not tolerate. Stability beats price here: these Pods are few, always on, and painful to lose. The Karpenter controller itself belongs outside Karpenter-managed capacity entirely, on Fargate or a small managed node group it cannot disrupt, because an autoscaler that can evict itself eventually will.
The web pool serves stateless services, allows Spot with on-demand fallback, and carries the consolidation tuning from later sections. The batch pool serves jobs, CI runners and data processing that tolerate interruption, runs Spot-heavy, and may use WhenEmpty consolidation so running work is never moved for a cheaper node. Three pools cover most clusters; a fourth pool should name the workload property the first three cannot express.
Taints enforce the separation. A pool taint such as pool=batch:NoSchedule means only Pods with the matching toleration land there, and tolerations become the visible contract between workload owners and the platform. The taints and tolerations lesson covers the mechanics; the design rule here is that every pool boundary should be readable from the taint and toleration pair alone.
When pools overlap and a Pod matches several, Karpenter prefers the pool with the higher weight. Weight is a tie-breaker, not a routing language, so keep overlaps rare and intentional. Per-team pools for cost attribution are the usual exception: identical shapes with different labels and taints, so cloud billing splits cleanly. That is a finance requirement wearing a scheduling costume, and it is fine when named as such.
4. Karpenter NodePool Spot patterns: interruption handling comes first
Karpenter NodePool Spot capacity costs far less than on-demand and can be reclaimed with a two-minute warning, so Spot patterns start with interruption handling, not with the capacity-type requirement. Wire the interruption queue, spread instance types widely, and run only workloads whose Pods survive replacement.
On AWS, Karpenter learns about Spot interruptions, rebalance recommendations and scheduled events through an SQS queue fed by EventBridge rules. Without that queue, Karpenter cannot drain a node ahead of reclamation, and Pods die with the instance instead of moving gracefully. Treat the queue as part of the Spot feature: a pool that allows Spot without interruption handling is a pool that accepts hard kills.
Workload readiness decides how much Spot a service can take. Stateless Pods with fast startup, honest readiness probes and PodDisruptionBudgets absorb interruptions as routine churn. Stateful Pods, singletons and slow starters belong on on-demand, or on Spot only with replicas spread so one interruption cannot take the quorum. The topology spread lesson covers spreading replicas so a single node loss stays a non-event.
Allow on-demand in the same pool as Spot for services. Karpenter prefers cheaper capacity and falls back to on-demand when Spot pools dry up, which converts a capacity outage into a cost blip. Spot-only pools suit batch work where pending Pods can wait for capacity to return. The distinction is a latency decision: services buy fallback, batch buys patience.
Watch interruption rates per pool after launch. Frequent interruptions in one family or zone usually mean requirements narrowed too far, not that Spot is unreliable in general. Widen the instance menu before abandoning Spot, and check whether consolidation is manufacturing extra churn that looks like interruptions in the graphs.
5. Karpenter NodePool consolidation: deleting nodes whose Pods fit elsewhere
Karpenter NodePool consolidation removes nodes whose Pods fit on other nodes, or replaces a node with a cheaper one that fits the same Pods. It runs after drift handling, prefers nodes that disrupt least, and drains through the eviction API so PodDisruptionBudgets still apply.
The mechanics are orderly. Karpenter simulates scheduling the node's Pods elsewhere, and only when every Pod fits does it act: taint the node so nothing new lands, start replacement capacity if the plan needs it, wait for readiness, then evict Pods respecting disruption budgets and grace periods. A node whose Pods cannot all move stays put. Consolidation is a scheduler simulation with a delete button, not a blind scale-down.
Two policies bound the behaviour. WhenEmptyOrUnderutilized considers any node that could be emptied or replaced more cheaply, which is the cost-saving default. WhenEmpty only removes nodes with no Pods left, which suits pools where moving a Pod costs more than the node saves: long batch jobs, stateful Pods with slow warm-up, or workloads whose restart is user-visible. Pick per pool, because the right answer differs between the web pool and the batch pool by design.
Consolidation interacts with the HPA in a way that needs one shared mental model. The HPA removes Pods when traffic falls; consolidation then removes the nodes those Pods emptied. When both react instantly, a brief traffic dip cascades into node deletions and re-launches. The quiet period in the next section exists to break that cascade. Node churn graphs that mirror HPA replica graphs are the signature of two loops tuned without knowledge of each other.
Replacement consolidation deserves its own caution. Swapping a node for a cheaper shape saves money only when the saving outlives the disruption, and spot-to-spot replacement features sharpen that trade. Keep replacement enabled where Pods are cheap to move, and let budgets and quiet periods decide the pace. Savings that cost a latency incident are not savings.
6. Karpenter NodePool consolidateAfter: the quiet period that prevents churn
Karpenter NodePool consolidateAfter sets how long a node must stay unchanged before consolidation may consider it, and the default of 0s makes nodes candidates the instant Pods change. Services with an HPA usually want 5 to 15 minutes, so a node must prove it is surplus before Karpenter acts.
The timer restarts whenever a Pod is added to or removed from the node. During a rollout, Pods churn constantly, so nodes stay ineligible until the rollout settles, which is exactly the protection a deploy needs. During a genuine traffic fall, nodes go quiet, the timer expires, and consolidation proceeds. One field separates deploy noise from real surplus, and it does so without any traffic awareness in Karpenter itself.
Setting consolidateAfter to Never disables consolidation for the pool while leaving expiry and drift active. That is a legitimate temporary posture during migrations, incident freezes or capacity investigations, and a suspicious permanent one, because idle nodes then bill forever. If a pool carries Never, the pool comment should carry the reason and the date it will be revisited.
Tune from evidence. Graph node count against replica count for a week; if nodes oscillate with every replica wiggle, lengthen the quiet period. If nodes sit half-empty for hours after peaks, shorten it. The HPA scale-down stabilization window from the previous lesson and consolidateAfter form one combined delay between traffic falling and money being saved, so tune them as a pair rather than as rival settings.
Batch pools read the same field differently. WhenEmpty with a short quiet period cleans up finished job nodes quickly, which is pure saving because no Pod moves. The expensive case is underutilized consolidation moving live Pods, so the quiet period matters most where the policy allows moves.
7. Karpenter NodePool disruption budgets: cap and schedule voluntary disruption
Karpenter NodePool disruption budgets cap how many nodes Karpenter may voluntarily disrupt at once, as a count or a percentage of the pool. The default allows 10 percent, and budgets can carry schedules so consolidation pauses during traffic peaks and resumes when the cluster is quiet.
Read the example as two rules. At most 10 percent of pool nodes may be disrupted at once in general. On weekday business hours, underutilized consolidation is blocked entirely, while empty-node cleanup and expiry still proceed. Budgets accept reasons, so a freeze can target the disruptive kind of consolidation without stopping harmless empty-node removal. That precision is what makes budgets usable as an operations control rather than a blunt off switch.
Budgets govern voluntary disruption only. Spot interruptions, node failures and expiry-driven replacement still happen, because the cloud does not consult your budget. What budgets buy is a ceiling on self-inflicted churn: a bad consolidation decision can only touch a bounded slice of the pool before a human notices. Small pools need count-based budgets, since 10 percent of four nodes rounds into behaviour nobody intended.
Pair budgets with PodDisruptionBudgets rather than confusing them. Karpenter budgets limit nodes in motion; PodDisruptionBudgets limit unavailable replicas of a workload, and Karpenter respects them during drains. A service with a strict PDB can stall consolidation indefinitely, which is correct behaviour for that service and a signal to check whether the PDB matches real availability needs. Stalled consolidation with PDB-blocked evictions in the events is the platform working as configured.
Schedule budgets around known peaks: campaigns, batch windows, regional business hours. The schedule syntax follows cron with a duration, so a freeze window is a reviewed line of YAML instead of a calendar reminder someone forgets. Review budget windows quarterly against traffic graphs, because last year's peak is not this year's.
8. Karpenter NodePool expiry: replace nodes on your schedule
Karpenter NodePool expireAfter sets a maximum node lifetime, after which Karpenter cordons, drains and replaces the node, bypassing disruption budgets while still respecting PodDisruptionBudgets during the drain. A 720h lifetime, thirty days, aligns rotation with AMI update cadence and bounds how stale node software can become.
Expiry converts node patching from a project into a background process. New AMIs roll out because nodes age out, kernel and kubelet updates land without a maintenance window, and long-lived node weirdness such as leaked mounts or full disks gets a bounded lifetime. Expiry bypasses disruption budgets, so a peak-hour budget freeze does not stop rotation; PodDisruptionBudgets still gate evictions during the drain, and terminationGracePeriod bounds the wait before Pods are force-deleted. Stagger node creation and expiry values across pools so a same-age fleet does not rotate all at once.
terminationGracePeriod bounds how long Karpenter waits for Pods to leave an expiring or disrupted node before forcing the issue. Set it from the slowest legitimate drain in the pool: a stateful Pod that needs ten minutes to hand over leadership should not discover a shorter grace period during its first expiry. Grace periods that are too long stall rotation; too short, they convert graceful drains into kills. Measure real drain times and set the value from data.
Expiry also interacts with drift. When a NodePool or NodeClass change makes running nodes non-compliant, Karpenter replaces them as drifted, through the same disruption machinery. Short expiry plus frequent template changes can double the churn, so batch template changes deliberately and watch NodeClaim replacements after each change. The event stream distinguishes expiry, drift and consolidation reasons, and reading it weekly keeps rotation boring.
Some pools should expire faster. Spot-heavy batch pools churn naturally and gain little from long lifetimes. Pools running sensitive workloads may rotate weekly to bound credential and patch exposure. The right lifetime is a risk decision with a number attached; 720h is a starting point, not a law.
9. Karpenter NodePool limits: the billing guardrail
Karpenter NodePool limits cap the total CPU and memory a pool may provision, and hitting the limit stops new launches while Pods stay pending. Set limits on every pool, sized around 110 to 120 percent of expected peak, so a runaway workload produces pending Pods and alerts instead of a billing surprise.
Limits are independent of cloud cost alerts, and that independence is the point. Cost alerts report after money is spent; pool limits refuse the spend. A misconfigured HPA with maxReplicas in the thousands, a retry storm spawning Jobs, or a load test pointed at the wrong cluster all meet the same wall. Pending Pods are a visible, debuggable failure. An unbounded node fleet is an invoice.
Size limits from the demand side. Sum the maxReplicas-driven requests of workloads allowed in the pool, add headroom for surge and zone loss, and set the cap there. Revisit the number when a service raises its HPA maximum, because the two ceilings form one system: the HPA decides Pods, the pool limit decides nodes, and the smaller effective ceiling wins. The scheduling lesson covers the Pod-side placement rules that interact with these caps.
Alert on approaching limits, not only on hitting them. A pool at 85 percent of its CPU limit during a normal week is a capacity review waiting to happen. Karpenter metrics and pending Pod age give the signal; the runbook should name who may raise a limit and what evidence they need. Raising limits during an incident without that evidence trades a scheduling problem for a cost problem at the worst possible time.
Limits also make Spot strategy honest. A batch pool with a generous limit and Spot-only capacity will wait for Spot rather than buying on-demand, which is the intended economics. A web pool limit set too low silently caps the HPA during the exact surge the HPA exists for. Write the sizing arithmetic in the pool comment so reviewers can check it in seconds.
10. Karpenter NodePool drift and do-not-disrupt: controlled exceptions
Karpenter NodePool drift replaces nodes whose configuration no longer matches the pool or NodeClass, keeping the fleet compliant with current templates. The karpenter.sh/do-not-disrupt annotation exempts specific Pods or nodes from voluntary disruption, for workloads whose movement cost exceeds any saving.
Drift is how template changes reach running nodes. Update the AMI in the NodeClass or a requirement in the pool, and nodes that no longer match become drift candidates, replaced through budgets and PDB-aware drains. This makes template changes safe to roll out gradually, and also makes them worth reviewing like deploys: a requirement typo can mark half the fleet drifted. Watch replacement rate after every template change and keep budgets tight enough that a mistake unfolds slowly.
do-not-disrupt is the escape hatch, and escape hatches need governance. Annotating a Pod keeps its node out of consolidation and voluntary replacement, which fits a singleton with slow state handover or a Pod mid-migration. Annotating broadly, or forgetting annotations after the reason passes, quietly disables the savings the pool exists for. Treat the annotation like a freeze: owner, reason and expiry date in a comment or ticket, reviewed on the same cadence as budgets.
PodDisruptionBudgets remain the workload-level control, and they compose with both mechanisms. Drift replacement and consolidation respect PDBs; do-not-disrupt stops the node being considered at all. A workload that needs strong protection usually wants a PDB sized to real availability, not a blanket annotation, because the PDB still allows movement when replicas are healthy. Reach for the annotation when movement itself is the harm, not merely unavailability.
Node-level exceptions belong in pool design where possible. If a class of workload must never move, give it a pool with WhenEmpty consolidation and long expiry rather than annotating every Pod. Exceptions expressed as pools are visible in one object; exceptions expressed as annotations hide across namespaces.
11. Karpenter NodePool troubleshooting: pending Pods and churn
Karpenter NodePool troubleshooting splits into two families: Pods that stay pending because no node launches, and nodes that churn because disruption fires too eagerly. Pending Pods point at requirements, limits or capacity. Churn points at consolidation settings, budgets and expiry arithmetic.
| Symptom | First check | Likely cause | Fix direction |
|---|---|---|---|
| Pods pending, no NodeClaim | Pool limits and requirements | Limit reached or requirements exclude all shapes | Raise limit with evidence; widen requirements |
| NodeClaim stuck launching | NodeClaim events, NodeClass | AMI, subnet or IAM problem in NodeClass | Fix NodeClass wiring; check cloud quotas |
| Nodes replaced during peaks | Disruption reason in events | consolidateAfter too short, no peak budget | Lengthen quiet period; add scheduled budget |
| Spot Pods die without drain | Interruption queue health | SQS queue or EventBridge rules missing | Wire interruption handling before Spot |
| Consolidation never happens | PDB-blocked evictions | Strict PDBs or do-not-disrupt spread widely | Right-size PDBs; audit annotations |
| Fleet rotates all at once | Node ages and budgets | Same-age nodes, budget too wide | Stagger creation; tighten budget percentage |
The NodeClaim object is the ground truth for launches. kubectl get nodeclaims shows what Karpenter decided to create, and describing a stuck claim names the failing step: capacity unavailable, launch template error, or registration timeout. Separate capacity problems, where the cloud has no suitable Spot pool right now, from configuration problems, where your objects ask for something invalid. The fixes live in different places and different teams.
Churn diagnosis starts with disruption reasons. Karpenter events and metrics label replacements as consolidation, drift, expiry or interruption, and each reason has a different knob. Teams that tune consolidateAfter for a drift problem waste a week. Read the reason distribution first, then turn exactly one knob, then watch a full traffic cycle before turning another.
Keep a pool review rhythm. Monthly, compare node cost per workload against replica demand, interruption rates against requirements breadth, and replacement reasons against expectations. NodePools drift out of tune as workloads change; the review is where limits, budgets and expiry get re-derived from current evidence instead of inherited defaults.
12. Karpenter NodePool production checklist
Karpenter NodePool production readiness means requirements stay broad, disruption respects traffic, expiry rotates nodes on schedule, and limits cap the worst case. The checklist below reviews a pool the way an incident review would: what launches, what moves, what it can cost, and what happens at peak.
| Review point | Healthy sign | Warning sign |
|---|---|---|
| Requirements | Several families, zones and architectures | Single instance type pinned |
| Spot readiness | Interruption queue wired and tested | Spot allowed with no queue |
| Consolidation | Quiet period tuned to traffic | 0s default on HPA-driven services |
| Budgets | Percentage cap plus peak freeze | No explicit budget written |
| Expiry | Lifetime matches AMI cadence | Nodes older than the patch policy |
| Limits | Sized from peak demand arithmetic | Absent or copied from another pool |
Production checklist
- The Karpenter controller runs outside Karpenter-managed capacity, on Fargate or a dedicated node group.
- Requirements allow several instance families and zones; Spot pools avoid single-type pinning.
- The Spot interruption queue and event rules are wired and tested before Spot capacity is allowed.
- Pools separate system, web and batch workloads with taints, and weight only breaks deliberate overlaps.
- consolidateAfter gives HPA-driven services a 5 to 15 minute quiet period; batch pools use WhenEmpty where moving Pods costs more than nodes save.
- Disruption budgets cap concurrent voluntary disruption and freeze underutilized consolidation during known peaks.
- expireAfter matches the AMI cadence, and terminationGracePeriod covers the slowest legitimate drain in the pool.
- Every pool carries CPU and memory limits sized from peak demand, with alerts before the cap is reached.
- PodDisruptionBudgets reflect real availability needs, and do-not-disrupt annotations carry an owner and an expiry date.
Node autoscaling earns trust the same way Pod autoscaling does: bounded behaviour, honest limits, and evidence before tuning. A Karpenter NodePool that saves money quietly during calm weeks and refuses to churn during peaks is doing both halves of its job. From here, Module 12 on delivery and GitOps takes over with Kubernetes deployment strategies, because capacity that scales still needs releases that arrive safely.
Frequently Asked Questions
How many Karpenter NodePool objects should a cluster run?
Most clusters run three shared Karpenter NodePool objects: a system pool for add-ons on on-demand capacity, a web pool for stateless services with Spot and fallback, and a batch pool for interruption-tolerant work. Add a pool only when a workload property such as architecture, compliance or cost attribution cannot be expressed by the existing three.
What consolidateAfter should a Karpenter NodePool use?
A Karpenter NodePool serving HPA-driven services usually wants consolidateAfter between 5 and 15 minutes, so a node must stay unchanged through rollout noise before consolidation considers it. The 0s default reacts instantly and churns during deploys. Batch pools using WhenEmpty can clean up faster because no live Pod moves.
How does Karpenter NodePool expiry affect running Pods?
Karpenter NodePool expiry cordons and drains the node through the eviction API, respecting disruption budgets and PodDisruptionBudgets, then launches replacement capacity. Pods move gracefully when terminationGracePeriod covers their real drain time. A 720h lifetime aligns rotation with monthly AMI updates for most production pools.
Why are Pods pending when my Karpenter NodePool has capacity?
Pods stay pending when a Karpenter NodePool limit is reached, when requirements exclude every instance shape that fits the Pod, or when Spot capacity is unavailable in the allowed pools. Check NodeClaim events first: they separate configuration problems in your objects from genuine cloud capacity shortages.
Should a Karpenter NodePool allow Spot and on-demand together?
A Karpenter NodePool for services should allow Spot and on-demand together, because Karpenter prefers cheaper capacity and falls back to on-demand when Spot pools dry up. Spot-only pools suit batch work that can wait for capacity. Either way, wire the interruption queue before allowing Spot, or reclaimed nodes kill Pods without draining.
What do Karpenter NodePool limits actually stop?
Karpenter NodePool limits stop new node launches once total provisioned CPU or memory reaches the cap, leaving Pods pending instead of spending. Size limits near 110 to 120 percent of expected peak so runaway demand fails visibly as pending Pods rather than silently as a cloud bill.
How do Karpenter NodePool budgets differ from PodDisruptionBudgets?
Karpenter NodePool budgets cap how many nodes Karpenter may voluntarily disrupt at once, optionally on a schedule. PodDisruptionBudgets cap how many replicas of one workload may be unavailable. Karpenter respects both during drains, so a strict PDB can stall consolidation even when the node budget has room.
Preparing for Senior Platform & SRE Interviews
Practice real-world cluster triage, RBAC debugging, and pod scheduling scenarios in our Kubernetes scenario interview questions hub.
Explore Interview Scenarios →