AWS Node Termination Handler: gracefully draining EC2 nodes in Kubernetes without dropping podsNote · digest for December 5
Isometric diorama of graceful Kubernetes pod evacuation from a draining EC2 node onto healthy server platforms following an AWS signal
Note3 sections≈ 4 min

AWS Node Termination Handler: gracefully draining EC2 nodes in Kubernetes without dropping pods

AWS gives you two minutes' notice before taking back a Spot instance or sending a VM into maintenance. Kubernetes doesn't know about this until kubelet times out. Meanwhile, the load balancer keeps sending traffic to the dying node, and live requests break mid-flight.

What NTH fixes and who actually needs it

The open-source AWS Node Termination Handler (NTH) catches cloud signals early and calls the Kubernetes API itself. First it runs cordon to block new pods from the node, then it runs drain to move running containers onto healthy machines.

You need NTH for self-managed clusters on EC2 and self-managed node groups in EKS. On EKS Managed Node Groups, it's unnecessary because AWS drains those nodes itself. The same goes for Karpenter: it has its own SQS handler, and running both controllers on the same events causes conflicts.

Release v1.25.7 (November 30, 2026) is tested on Kubernetes 1.29–1.32, fixes a taint race condition, and updates builds to Go 1.26. Windows Server 2019 support is dropped; you now need at least Windows Server 2022.

IMDS DaemonSet vs SQS Queue Processor

NTH has two mutually exclusive modes controlled by enableSqsTerminationDraining. When you turn on the SQS queue, metadata polling turns off completely.

IMDS Processor (enableSqsTerminationDraining=false) runs as a DaemonSet and polls the local Instance Metadata Service (IMDS) at 169.254.169.254 on each EC2 node. It needs no queues or IAM setup, but on a Rebalance Recommendation it only runs cordon unless you set enableRebalanceDraining=true.

Queue Processor (enableSqsTerminationDraining=true) runs as a Deployment and reads an SQS queue fed by EventBridge. It takes more setup, but it sees cluster-wide events and supports ASG Lifecycle Hooks. Those Auto Scaling Group hooks hold a node in Terminating:Wait until pods finish moving.

Event or featureIMDSQueue
Spot Interruption (ITN)YesYes
Scheduled EC2 maintenanceYesYes
Instance Rebalance RecommendationYesYes
ASG Termination Lifecycle HooksNoYes
ASG Lifecycle State ChangeYesNo
AZ Rebalance RecommendationNoYes
Termination via EC2 API / consoleNoYes
Lifecycle Heartbeats (up to 48h)NoYes

If you terminate a node manually via the EC2 API, there is no pause even with a queue. The OS sends SIGTERM to kubelet right away, leaving pods only podTerminationGracePeriod (30s by default, roughly 90s max).

Helm install and the Lifecycle Heartbeats trap

Helm chart version 0.27.7 lives in ECR Public (log Helm into public.ecr.aws first). Basic flags are enough to start in IMDS mode:

# IMDS Processor mode: DaemonSet on every node
helm upgrade --install aws-node-termination-handler \
  --namespace kube-system \
  --set enableSpotInterruptionDraining="true" \
  --set enableRebalanceMonitoring="true" \
  --set enableScheduledEventDraining="true" \
  oci://public.ecr.aws/aws-ec2/helm/aws-node-termination-handler \
  --version 0.27.7

This DaemonSet immediately starts catching Spot interruptions and scheduled maintenance on every node without queues or IAM roles.

For long jobs like ML inference, two minutes isn't enough. In Queue Processor mode, Lifecycle Heartbeats send 'still working' signals that reset the ASG Heartbeat Timeout and stretch the pause up to 48 hours (or 100 Heartbeat Timeout intervals, whichever is less):

# Queue Processor mode with SQS and Heartbeat extensions
helm upgrade --install aws-node-termination-handler \
  --namespace kube-system \
  --set enableSqsTerminationDraining=true \
  --set queueURL=https://sqs.us-east-1.amazonaws.com/0123456789/term-q \
  --set heartbeatInterval=1000 \
  --set heartbeatUntil=4500 \
  oci://public.ecr.aws/aws-ec2/helm/aws-node-termination-handler \
  --version 0.27.7

The heartbeatInterval flag (30–3600s) sets how often heartbeats fire, and heartbeatUntil (60–172,800s) sets the window for sending them. It looks like heartbeatUntil=4500 will terminate the node at 4,500 seconds, but the math is trickier.

With a Heartbeat Timeout of 3,000 seconds, NTH sends four heartbeats (at 1000, 2000, 3000, and 4000s), resetting the timer back to 3,000 each time. At 4,500s, it stops extending, leaving 2,500 seconds on the clock. So the machine isn't terminated until 7,000 seconds.

Keep heartbeatInterval well below Heartbeat Timeout so the timer doesn't expire while a message is in transit from SQS. Also check workers: it defaults to 10, so during a large cluster scale-down, the controller won't drain more than ten nodes at once.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 5