Skip to main content

How do we scale a MachineDeployment down to zero?

Syself support For release

To scale a node pool to zero, set replicas: 0 on the pool's machineDeployments entry in the Cluster object and apply it like any Kubernetes resource, with kubectl or a GitOps tool. Syself Autopilot drains and removes every node in the pool. The pool stays in the cluster, empty, and gets nodes again when you raise replicas.

What this does to your Hetzner invoice depends on the pool. Cloud servers are deleted, so you stop paying for them. Bare-metal servers go back to your inventory and stay in your Hetzner account until you cancel them there.

For a cloud pool that the Cluster Autoscaler manages, leave replicas out and set the pool's minimum size annotation (cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size) to "0". The maximum size annotation stays as it is. The autoscaler then removes the last node when no pod needs it, and adds nodes again when pods are pending that fit the pool. The first of these pods waits until a new node has joined the cluster. To also remove a workload's pods while it is idle, so that its nodes become free, see Scale a workload to zero.

What happens to the nodes on scale-down is described in Scale a node pool. For the autoscaler setup and an example of a pool that scales to zero, see Autoscale node pools.

Still stuck?

Prepare your case, then email us.