Create a DigitalOcean Managed Kubernetes Cluster with Node Autoscaling Enabled
Step‑by‑step guide to create a DigitalOcean Managed Kubernetes cluster with node autoscaling, including prerequisites, commands, verification, and recovery options.
08 Jul 2025, 14:06 UTC

Desired Outcome
Create a fully functional DigitalOcean Managed Kubernetes (DOKS) cluster that automatically adjusts the number of worker nodes based on workload demand, providing cost‑efficient scaling and high availability.
Prerequisites
- A DigitalOcean account with sufficient quota for at least one worker node.
- A Personal Access Token (PAT) with
read/writescope generated in the account settings. - The
doctlCLI installed and configured with the PAT (doctl auth init). kubectlinstalled locally (version compatible with the cluster, e.g., v1.27+).- Basic familiarity with Kubernetes concepts such as pods, deployments, and node pools.
Procedure
- Create the cluster with autoscaling enabled
Run the following command, replacing placeholders with your preferred values:
doctl k8s cluster create \ --region \ --node-pool name=,size=,min-nodes=,max-nodes=Example:
doctl k8s cluster create my-doks-cluster \ --region nyc1 \ --node-pool name=worker-pool,size=s-2vcpu-4gb,min-nodes=1,max-nodes=5 - Wait for the cluster to reach the
runningstateCheck status periodically:
doctl k8s cluster listWhen the
STATUScolumn showsrunning, proceed. - Retrieve and set the kubeconfig
doctl k8s kubeconfig save export KUBECONFIG=${HOME}/.kube/config - Verify the node pool autoscaling parameters
Inspect the node pool labels to confirm min/max settings:
kubectl get nodes -l doctl.digitalocean.com/node-pool= -o wideThe output should list nodes whose count is currently between
and.
Verification
- Confirm API accessibility
kubectl get nodesYou should see the control plane endpoint reachable and a list of worker nodes.
- Check that the cluster autoscaler is running
kubectl -n kube-system get pods -l app=cluster-autoscalerEnsure the pod status is
Running. - Trigger a scale‑up event
Deploy a workload that requests more resources than currently available. For example, a busybox loop that requests 500m CPU:
cat <<EOF | kubectl apply -f - apiVersion: v1 kind: Pod metadata: name: cpu-loader spec: containers: - name: loader image: busybox command: ["sh", "-c", "while true; do echo hello; sleep 10; done"] resources: requests: cpu: "500m" memory: "256Mi" restartPolicy: Never EOFAfter a few moments, run
kubectl get nodesagain. If the current node count is at the minimum and the pod cannot be scheduled, the autoscaler should add a node (up to themax-nodeslimit). - Inspect autoscaler logs for confirmation
kubectl -n kube-system logs deployment/cluster-autoscaler --tail=20Look for lines similar to
pod triggered scale-up: ...orscale-down: ...indicating the autoscaler is active.
Recovery Options
If autoscaling does not behave as expected:
- Manually adjust the node pool size
doctl k8s node-pool update \ --cluster \ --node-countThis changes the desired count immediately; the autoscaler will still respect the
min-nodes andmax-nodes bounds. - Recycle the cluster
As a last resort, delete and recreate the cluster with the same specification. Ensure any persistent volumes have snapshots or backups enabled before deletion.
doctl k8s cluster delete # after confirmation, recreate using the same command from step 1
Limitations and Practical Checks
- Autoscaling may cause additional charges if the node count reaches the
max-nodeslimit. Monitor usage via DigitalOcean billing alerts or thedoctl accountcommand. - Changing autoscaling parameters (
min-nodesormax-nodes) requires a cluster upgrade window and may cause brief disruption while nodes are provisioned or terminated. - To verify that the autoscaler respects the bounds, repeatedly run
kubectl get nodeswhile applying and removing load‑generating pods, ensuring the node count never falls belowmin-nodesor exceedsmax-nodes.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.