Skip to content

08 ยท Watch consolidation

Goal: see the spot-burst disruption contract in action: once the batch finishes, the Spot nodes it caused go away on their own, while the static nodes stay exactly where they are.

About three minutes after you applied the job, its pods complete. Check:

kubectl -n demo-nodepools get job report-batch
NAME           STATUS     COMPLETIONS   DURATION   AGE
report-batch   Complete   12/12         3m26s      3m40s

Now watch the NodeClaims:

kubectl get nodeclaims -w

What happens next:

  1. The Spot nodes are now empty (only daemon pods, if any).
  2. consolidateAfter: 1m: each has to stay unchanged for a minute before it's a candidate.
  3. Balanced scores the move. Removing an empty node saves money and disrupts nothing, so it's approved.
  4. The 30% budget limits how many go at once, so they may leave in waves.
  5. The NodeClaims are deleted and the instances terminated.

In the test run, both Spot nodes were gone about two minutes after the job completed. Only the two stable-static NodeClaims remain (plus the built-in system ones). Press Ctrl+C and confirm:

kubectl get nodes -L karpenter.sh/nodepool,karpenter.sh/capacity-type

Why it happened, from the controller's side

Auto Mode records disruption decisions as Kubernetes events. Look at what it said about the Spot NodeClaims:

kubectl get events -A --sort-by=.lastTimestamp \
  -o custom-columns='TIME:.lastTimestamp,SOURCE:.source.component,REASON:.reason,OBJECT:.involvedObject.name,MESSAGE:.message' \
  | grep -iE 'disrupt|consolidat|empty|nodeclaim' | tail -20

The lines for a Spot node look like this (columns trimmed):

SOURCE                  REASON                           OBJECT             MESSAGE
eks-auto-mode/compute   DisruptionTerminating            spot-burst-2hsjf   Disrupting NodeClaim: Empty
eks-auto-mode/compute   TerminationGracePeriodExpiring   spot-burst-2hsjf   All pods will be deleted by ...
eks-auto-mode/compute   InstanceTerminating              spot-burst-2hsjf   Instance is terminating
karpenter               Drained                          spot-burst-2hsjf   Status condition transitioned, Type: Drained, ...

Note the SOURCE column. The decision (Disrupting NodeClaim: Empty) comes from eks-auto-mode/compute; only the generic status-condition change is still reported as karpenter. More on that in the break-it lab.

Events expire

Kubernetes keeps events for about an hour by default. If you come back later, they'll be gone. For a durable record, enable the Auto Mode vended logs (see References).

Meanwhile, on the static pool

Nothing. stable-static isn't eligible for consolidation at all. Its two nodes are still there, with checkout-api still running on them. They'll only be replaced by expiry (before 20 days) or drift (outside business hours, one at a time). That's the opposite contract on the same NodeClass.

You now have the full happy path. The optional labs break things, or go straight to Cleanup.