Talos worker nodes on spot instances not scaling down during idle periods
0 reputation · 31 Jan 2022, 19:02 UTC
0 reputation · 31 Jan 2022, 19:02 UTC
I am planning a low-traffic Kubernetes workload on Talos Linux and want to keep costs down by running worker nodes on spot/preemptible instances with the Kubernetes cluster-autoscaler handling capacity. The intent is that during idle periods the cluster shrinks to a minimal node count, and scales back out only when real load appears.
Talos is immutable and API-driven, so all node lifecycle behavior is declared through machine configuration rather than tuned interactively on the host. There is no SSH or shell access; everything goes through talosctl and the Talos API. Assume a current Talos release and a single-cloud deployment, with the autoscaler deployed as an in-cluster component.
The open decision is how aggressively scale-down should be configured for a workload that is idle most of the time. Spot reclamation is already an availability risk, and an overly eager scale-down policy could compound it by evicting pods onto nodes that may themselves be reclaimed. Conversely, conservative settings may leave nodes running and erase the cost savings that motivated the design. I have not yet confirmed which autoscaler scale-down settings are safe to combine with spot-backed Talos workers, or how to validate the behavior before relying on it.
For a mostly idle workload on spot-backed Talos workers, configure the cluster-autoscaler with these flags:
--scale-down-utilization-threshold=0.3 (30%) — lower than the default 50% so nodes with minimal pods become candidates.--scale-down-unneeded-time=20m — extended from the default 10m to avoid removing nodes during transient dips.--scale-down-delay-after-add=10m and --scale-down-delay-after-delete=10m — prevent thrashing after scaling events.--scale-down-delay-after-failure=3m — safe default.--scale-down-unready-time=5m — lets the autoscaler act on unready nodes (e.g., spot termination notice) without waiting for utilization checks.These values assume cluster-autoscaler v1.28+ and a single cloud provider. If you run mixed instance types in one ASG, split into separate node groups per instance type; the autoscaler's unneeded-time logic does not account for instance diversity.
minAvailable: 2.kubectl scale deployment cluster-autoscaler --replicas=0 -n kube-system.kubectl get events -w --field-selector reason=Evicted.kubectl cordon <node> && kubectl drain <node> --ignore-daemonsets --delete-emptydir-data.kubectl get nodes -w.Talos has no dedicated drain timeout; drain behavior is driven by the kubelet's --pod-eviction-timeout (default 5m) and your PodDisruptionBudgets. Set the kubelet flag via machine config:
machine:
kubelet:
extraArgs:
pod-eviction-timeout: "5m0s"Verify with talosctl get machineconfig -n <worker-ip> | grep pod-eviction-timeout. Also ensure:
cluster.allowSchedulingOnControlPlanes: false — control planes must not be spot-backed.topology.kubernetes.io/zone labels for zone-aware scaling.Install the cloud provider's spot termination handler as a DaemonSet (AWS Node Termination Handler, GCP Spot Termination Notifier, Azure Spot Termination Notifier). It cordons and drains nodes on the 2-minute notice, complementing autoscaler decisions. Confirm it runs: kubectl get ds -n kube-system | grep -i termination.
Without this handler, PDBs do not protect against involuntary spot termination.
What cloud provider and instance group / ASG configuration are you using? The autoscaler's --nodes spec must match your group's min/max exactly, and some providers (e.g., AWS mixed-instances policies) require separate node groups per instance type for predictable scale-down.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.