✦ For everyone, free.

Practical knowledge for real and everyday life

Home

Kubernetes Node Scale Down Flow

Kubernetes Node Scale Down Flow explains how nodes are efficiently scaled down in a cluster, optimizing resource usage and cost.

Kubernetes Node Scale Down Flow is the sequence of checks and actions the Cluster Autoscaler performs to identify an underutilized node, verify it is safe to remove, and gracefully evacuate its workloads before terminating the underlying instance, structured to avoid disrupting availability while still reclaiming unnecessary capacity.


Identifying Scale-Down Candidates

Utilization Threshold Evaluation

The autoscaler periodically evaluates each node's resource utilization against a configured threshold; a node whose requested resources (not actual usage, but the sum of pod resource requests) fall below this threshold for a sustained period becomes a candidate for removal.

--scale-down-utilization-threshold=0.5
--scale-down-unneeded-time=10m

Sustained Duration Requirement

A node must remain below the utilization threshold continuously for the configured scale-down-unneeded-time before being marked eligible, preventing a brief dip in utilization from triggering premature removal of a node that may become needed again shortly afterward.


Verifying Safety of Removal

Simulating Rescheduling of Existing Pods

Before proceeding, the autoscaler simulates whether every pod currently on the candidate node could be successfully rescheduled onto other existing nodes in the cluster, accounting for resource requests, affinity and anti-affinity rules, and taints and tolerations — if any pod cannot be placed elsewhere, the node is not removed.

Checking for Blocking Conditions

Certain pod characteristics prevent a node from being considered safe to scale down regardless of utilization: pods without a controller (bare pods, since the autoscaler cannot recreate them elsewhere), pods using node-local storage that would be lost, pods with a restrictive PodDisruptionBudget that would be violated by eviction, and pods explicitly annotated to block eviction.

metadata:
  annotations:
    cluster-autoscaler.kubernetes.io/safe-to-evict: "false"

Respecting Node-Level Exclusions

A node explicitly annotated as excluded from scale-down, or belonging to a node group already at its configured minimum size, is skipped regardless of its utilization, since removing it would either violate an explicit operational decision or breach the group's configured floor.

metadata:
  annotations:
    cluster-autoscaler.kubernetes.io/scale-down-disabled: "true"

Executing the Removal

Cordoning the Node

Once a node passes all safety checks, the autoscaler cordons it, marking it unschedulable so no new pods are placed there while the drain proceeds, without immediately affecting the pods already running on it.

kubectl cordon <node-name>

Draining Existing Pods

The autoscaler then evicts the node's pods following standard eviction semantics, respecting PodDisruptionBudgets and allowing each pod's configured terminationGracePeriodSeconds for graceful shutdown, with the Kubernetes scheduler placing evicted pods onto other nodes with sufficient capacity as they are recreated by their owning controllers.

kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-data

Terminating the Underlying Instance

After all pods have been successfully evicted and rescheduled, the autoscaler calls the cloud provider's API to terminate the underlying instance, completing the node's removal from both the cluster and the cloud provider's infrastructure.


Failure and Retry Behavior

Aborting on Simulation or Drain Failure

If the initial rescheduling simulation indicates a pod cannot be placed elsewhere, or if the drain itself encounters a pod that cannot be evicted within its grace period, the autoscaler aborts the scale-down for that node and uncordons it (or leaves it for reconsideration on the next evaluation cycle), rather than forcibly terminating a node with pods that could not be safely relocated.

Re-Evaluation on the Next Cycle

A node that fails scale-down consideration due to a transient condition (a PodDisruptionBudget temporarily blocking eviction during another concurrent disruption, for instance) is simply re-evaluated on the autoscaler's next cycle, without requiring manual intervention to retry.


Operational Considerations

Balancing Aggressiveness Against Stability

A shorter scale-down-unneeded-time and lower utilization threshold reclaim idle capacity faster but risk more frequent node churn and the associated pod rescheduling disruption; tuning these values reflects a deliberate tradeoff between cost efficiency and workload stability specific to a cluster's usage patterns.

Monitoring Scale-Down Activity

Reviewing autoscaler logs for scale-down attempts, including those blocked by safety checks, reveals both how effectively the cluster is reclaiming idle capacity and which specific workloads or configurations are preventing nodes from being removed when they otherwise appear eligible.