AKS Cost Optimization: Rightsizing, Node Auto-Provisioning, Spot and Commitments
Reduce Azure Kubernetes Service cost in the right order: namespace cost visibility, pod rightsizing, cluster autoscaler or node auto-provisioning, Spot, Arm64 and commitments.
Most AKS cost reviews start in the wrong place. Teams compare VM prices or ask about reservations while the cluster is running twice the nodes its workloads need. On AKS the bill is mostly node virtual machines, and the number of nodes is decided by what pods request, not by what they use. Fix the requests, let the node layer follow, and only then commit to a discount.
This guide walks through that order for AKS specifically. For the cross-cloud view, see the Kubernetes cost optimization playbook for EKS, AKS and GKE.
What an AKS cluster actually bills for
| Cost | Where it comes from | Typical lever |
|---|---|---|
| Node VMs | Virtual machine scale sets behind each node pool | Requests, autoscaling, Spot, Arm64, commitments |
| Control plane | The Standard and Premium tiers charge a per-cluster hourly fee. The Free tier does not, and has no uptime SLA. | Use Free for disposable dev clusters |
| Disks | OS disks and persistent volumes | Ephemeral OS disks, cleaning up released volumes |
| Networking | Load balancers, public IPs, NAT gateway, egress and cross-zone traffic | Fewer public load balancers, zone-aware routing |
| Monitoring | Log Analytics ingestion from Container insights and control plane logs | Collect less, use cheaper log tiers |
Check the AKS pricing tiers page for current tier details. In most production clusters the first row is the large majority of spend, and the last row is the one nobody budgeted for.
Step 1: See cost by namespace, not by scale set
Azure Cost Management shows AKS as scale sets, disks and IP addresses. That tells finance what was spent but not which team spent it. The AKS cost analysis add-on allocates cluster infrastructure cost to Kubernetes constructs such as namespaces, and shows it inside Cost Management. It requires the Standard or Premium tier.
az aks update \
--resource-group rg-platform-prod \
--name aks-prod-eastus \
--enable-cost-analysis
Give it a full billing cycle if you can, then note two figures per namespace: allocated cost and idle cost. Idle cost is capacity that was paid for and not requested by any pod. A high idle share points at the node layer. A low idle share with a high bill points at requests.
Step 2: Fix requests before touching nodes
The scheduler places pods by their CPU and memory requests. The autoscaler adds nodes when requests do not fit. If a service requests 2 vCPU and uses 300 millicores, the cluster buys the 2 vCPU. No node-level setting corrects that.
Start with a quick comparison of requests and live usage:
kubectl top pods --all-namespaces --sort-by=cpu | head -30
kubectl get pods --all-namespaces \
-o custom-columns='NS:.metadata.namespace,POD:.metadata.name,CPU_REQ:.spec.containers[*].resources.requests.cpu,MEM_REQ:.spec.containers[*].resources.requests.memory'
A point-in-time view misses peaks, so use the Vertical Pod Autoscaler in recommendation mode for anything you plan to change. Enable the managed add-on, then create a VPA object with updates turned off:
az aks update --resource-group rg-platform-prod --name aks-prod-eastus --enable-vpa
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: checkout-api
namespace: shop
spec:
targetRef:
apiVersion: apps/v1
kind: Deployment
name: checkout-api
updatePolicy:
updateMode: "Off"
After the workload has run through a normal cycle, including its busiest period, read the recommendation with kubectl describe vpa checkout-api -n shop and apply the new requests through your normal deployment process. Microsoft's guidance is explicit on one risk: do not run VPA and the Horizontal Pod Autoscaler against the same CPU or memory metric. If a service scales horizontally on CPU, keep VPA in recommendation mode for it.
Set memory requests with more care than CPU. An under-requested CPU throttles. A container that exceeds its memory limit is killed.
A worked example
This is illustrative arithmetic, not a customer result or a forecast.
A cluster runs 12 nodes with 8 vCPU each, 96 vCPU in total. Pods request 60 vCPU. Observed 95th percentile usage across the same pods is 24 vCPU. The team resets requests to peak usage plus about 40 percent headroom, which comes to roughly 34 vCPU.
At a target of 75 percent requested CPU per node, each node carries about 6 vCPU of requests. The workloads now need 34 / 6, which rounds up to 6 nodes. With one spare node for surge and zone balance, the cluster settles at 7 nodes, down from 12. That is about 42 percent fewer node hours, before any discount is applied. Memory has to pass the same check, and in many clusters memory is the constraint that sets the final node count.
Step 3: Let the node layer shrink
Right-sized requests only save money when nodes are removed. AKS gives you two mechanisms. Choose one as the scaling model for a cluster.
Cluster autoscaler
The cluster autoscaler adds and removes nodes within the node pools you define. Its defaults are conservative. The autoscaler profile applies to every autoscaled pool in the cluster:
az aks update \
--resource-group rg-platform-prod \
--name aks-prod-eastus \
--cluster-autoscaler-profile \
scale-down-unneeded-time=5m \
scale-down-utilization-threshold=0.6 \
expander=least-waste
Scale-down is commonly blocked by pods the autoscaler will not move: pods with local storage, pods without a controller, and pods covered by a PodDisruptionBudget that allows zero disruptions. Check the autoscaler status ConfigMap and events before assuming the settings are wrong.
Node auto-provisioning
Node auto-provisioning (NAP) is the AKS implementation of Karpenter. Instead of scaling fixed pools, it reads pending pod requirements and creates nodes of a suitable VM size, then consolidates workloads onto fewer or cheaper nodes over time. You describe what is allowed in a NodePool resource:
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
name: general
spec:
template:
spec:
nodeClassRef:
group: karpenter.azure.com
kind: AKSNodeClass
name: default
requirements:
- key: karpenter.sh/capacity-type
operator: In
values: ["on-demand"]
- key: kubernetes.io/arch
operator: In
values: ["amd64", "arm64"]
- key: karpenter.azure.com/sku-family
operator: In
values: ["D", "E"]
limits:
cpu: "200"
disruption:
consolidationPolicy: WhenEmptyOrUnderutilized
consolidateAfter: 5m
budgets:
- nodes: "10%"
Three settings deserve attention. limits caps the total capacity the pool can create, which is your protection against a runaway deployment. consolidateAfter controls how long a node must be a consolidation candidate before NAP acts, and a very low value causes churn. budgets limits how many nodes can be disrupted at once. If you leave it out, the default is a single budget of 10 percent of nodes. NAP has documented limitations. Windows node pools and IPv6 clusters are not supported, and a cluster with NAP enabled cannot be stopped. Read the current requirements before enabling it on an existing cluster.
AKS Automatic clusters turn on NAP, VPA, HPA and KEDA by default and enforce resource requests through deployment safeguards. For a new cluster with no special constraints, that is a reasonable starting point.
Step 4: Move the right workloads to Spot and Arm64
Spot node pools run on spare Azure capacity at a discount Microsoft describes as up to 90 percent compared with pay-as-you-go. They have no SLA and Azure can evict the nodes when it needs the capacity. A Spot pool cannot be a system pool.
az aks nodepool add \
--resource-group rg-platform-prod \
--cluster-name aks-prod-eastus \
--name spotd8 \
--priority Spot \
--eviction-policy Delete \
--spot-max-price -1 \
--enable-cluster-autoscaler \
--min-count 0 \
--max-count 20 \
--node-vm-size Standard_D8s_v5
AKS taints Spot nodes with kubernetes.azure.com/scalesetpriority=spot:NoSchedule, so nothing lands there by accident. Workloads opt in with a toleration:
tolerations:
- key: kubernetes.azure.com/scalesetpriority
operator: Equal
value: spot
effect: NoSchedule
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
preference:
matchExpressions:
- key: kubernetes.azure.com/scalesetpriority
operator: In
values: ["spot"]
Good candidates are stateless services with several replicas, batch jobs, CI runners and development environments. Keep enough on-demand capacity for the replicas that must survive an eviction wave, and use more than one VM size where you can.
Arm64 node pools on Azure Cobalt processors are the other compute lever. Microsoft cites up to 50 percent better price-performance than comparable x86 VMs for scale-out workloads. The requirement is multi-architecture container images, so begin with services built from languages and base images that already publish Arm64 variants.
Step 5: Stop paying for clusters nobody is using
- User node pools can scale to zero. System pools cannot. Put development, batch and GPU workloads in user pools with a minimum count of zero.
- KEDA scales workloads to zero replicas on event sources such as queue length, which lets the node layer remove the nodes behind them.
- Whole clusters can be stopped.
az aks stopshuts down the control plane and all node pools and keeps cluster state for the next start. A scheduled stop for non-production clusters outside working hours removes most of their compute cost. Clusters with node auto-provisioning enabled cannot be stopped, so scale their workloads to zero instead.
Step 6: Trim monitoring and storage
Container insights can generate a Log Analytics bill that rivals a node pool. Three changes usually cover most of it:
- Move metrics to managed Prometheus and disable metric collection in Container insights through the data collection rule.
- For control plane logs, collect only the categories you use.
kube-audit-adminrecords far fewer events thankube-auditbecause it excludes read operations. - Send verbose, rarely queried logs to a cheaper table plan, and filter noisy namespaces at the source.
On storage, look for persistent volumes in the Released state. A reclaim policy of Retain keeps the managed disk, and its charge, after the claim is deleted. Ephemeral OS disks avoid a separate OS disk charge and make node start faster, on VM sizes that support them.
Step 7: Commit last
Azure Reservations and the Azure savings plan for compute both reduce the rate you pay for a baseline. Microsoft lists reservation discounts of up to 72 percent on one-year or three-year terms. Reservations fit a stable VM family in a fixed region. A savings plan is an hourly spend commitment that applies across VM families and regions, which suits clusters where NAP or autoscaling changes the instance mix.
Commit only after steps 2 to 5 have settled. A commitment sized against 12 oversized nodes locks in the waste for the term. Size it against the on-demand floor of the right-sized cluster, and leave Spot and bursty capacity uncovered. The Azure cost optimization guide covers the commitment decision in more detail.
The order that works
- Turn on cost analysis and find idle cost by namespace.
- Reset requests from measured usage, with VPA in recommendation mode.
- Tune the cluster autoscaler or adopt node auto-provisioning so nodes actually leave.
- Move tolerant workloads to Spot and compatible ones to Arm64.
- Scale non-production to zero outside working hours.
- Cut log ingestion and orphaned disks.
- Buy commitments against what remains.
If a cluster has been through one cleanup and the bill came back, the missing piece is usually ownership and review cadence, not another tool. That is the focus of CloudForge's Kubernetes cost optimization engagements.
Sources
Want this applied to your clusters?
CloudForge measures where cluster spend goes, right-sizes workloads and tunes autoscaling so nodes actually leave when load drops.
See Kubernetes cost optimization