Enable DOKS Cluster Autoscaler with Node Pool Min/Max
This sequence enables the cluster autoscaler on a DOKS node pool by setting min and max node counts via doctl, which patches the cluster's autoscaler configuration through the DO API. Internally, DOKS runs a managed cluster-autoscaler deployment in kube-system that watches for unschedulable pods, evaluates node utilization via the cluster-autoscaler cloud provider (DigitalOcean), and calls the DO API to scale node pools up or down. The min/max values are stored on the node pool object and enforced by the autoscaler, which respects PodDisruptionBudgets, node taints, and scale-down cooldowns before removing a node.
Production teams use this to keep costs bounded while absorbing traffic spikes, particularly for batch jobs, CI runners, and web frontends with diurnal load. It is the correct choice when you want node-level elasticity rather than pod-level (HPA). Combine it with HPA and node affinity to ensure the autoscaler can actually place new pods on the right pool. For GPU workloads, set a separate pool with min 0 so you only pay when training jobs are queued.
Security implications: the autoscaler runs with a DO API token mounted in-cluster, so restrict RBAC on the cluster-autoscaler service account and audit who can edit node pools. Performance-wise, scale-up is typically 60-120 seconds including node bootstrap and CNI readiness, so set HPA min replicas accordingly. Common pitfalls include setting max too low so pods stay Pending, forgetting that scale-down is disabled if any pod lacks a controller, and using a service account token with write access to unrelated resources. Always set --balance-similar-node-groups for multi-pool clusters and monitor cluster_autoscaler_unschedulable_pods_count.
> System.Execute()
doctl kubernetes cluster node-pool update prod-cluster-01 prod-pool-01 \
--min-nodes 2 --max-nodes 12 --auto-scale
# Verify autoscaler is running
doctl kubernetes cluster node-pool get prod-cluster-01 prod-pool-01 --format ID,Name,MinNodes,MaxNodes,AutoScale
kubectl -n kube-system logs deploy/cluster-autoscaler --tail=100 | grep -i 'scale'
# Annotate a workload to prefer a specific pool
kubectl annotate deploy web \
cluster-autoscaler.kubernetes.io/safe-to-evict=true --overwrite
> Architecture & Security Context
Verified for Valters IT Hub. When deploying this configuration in a production homelab or enterprise environment, ensure that you monitor system resources and implement strict access controls. Administrator privileges are required.
ID: VALTERSIT-2F049F73D053