Azure AKS Cost Allocation lets you track shared infrastructure costs (like VMs, load balancers, and disks) by Kubernetes namespaces and workloads using Microsoft’s native OpenCost integration. This feature is available on Standard or Premium tier clusters only.
⚙️ Prerequisites
Before enabling cost allocation:
- Your cluster must be on the Standard or Premium tier (not Free).
- Azure AD Workload Identity must be enabled.
- Your account must have Owner or Contributor access to the AKS subscription.
- Supported only on EA and MCA subscriptions (not CSP).
🚀 Option 1: Enable Cost Allocation During Cluster Creation
Use this if you’re creating a new AKS cluster with the Azure CLI:
bashCopyEditaz aks create -g <resource-group> -n <cluster-name> --tier standard --enable-cost-analysis
✅ Result: The cost analysis feature will be active from day one.
🔄 Option 2: Enable Cost Allocation on an Existing Cluster
You can add cost allocation to an existing Standard-tier cluster via CLI:
bashCopyEditaz aks update -g <resource-group> -n <cluster-name> --enable-cost-analysis
Alternatively, in the Azure Portal:
- Go to your AKS cluster.
- Look for the Cost Analysis section.
- If available, you’ll be prompted to enable cost allocation.
✅ Result: The add-on will be installed, and cost tracking begins.
📊 After Enabling
- Data will begin flowing into Azure Cost Management after a short delay.
- In Cost Management > Cost Analysis, you’ll be able to:
- Change the view to Kubernetes cluster scope
- See costs by namespace, controller, and workload
This visibility helps teams monitor their usage in shared clusters for showback or internal chargeback.
⚠️ Important Notes
- You cannot downgrade the cluster to Free tier while cost analysis is enabled.
- This feature doesn’t split billing—just visibility.
- For more granular detail (e.g., per pod label), you can also install Kubecost, which is based on OpenCost.