You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Azure Kubernetes Service cost analysis (preview)
2
+
title: Azure Kubernetes Service cost analysis
3
3
description: Learn how to use cost analysis to surface granular cost allocation data for your Azure Kubernetes Service (AKS) cluster.
4
4
author: nickomang
5
5
ms.author: nickoman
6
6
ms.service: azure-kubernetes-service
7
7
ms.custom: ignite-2023, devx-track-azurecli
8
8
ms.topic: how-to
9
-
ms.date: 11/06/2023
9
+
ms.date: 03/15/2024
10
10
11
11
#CustomerIntent: As a cluster operator, I want to obtain cost management information, perform cost attribution, and improve my cluster footprint
12
12
---
13
13
14
-
# Azure Kubernetes Service cost analysis (preview)
14
+
# Azure Kubernetes Service cost analysis
15
15
16
-
An Azure Kubernetes Service (AKS) cluster is reliant on Azure resources like virtual machines, virtual disks, load-balancers and public IP addresses. These resources can be used by multiple applications, which could be maintained by several different teams within your organization. Resource consumption patterns of those applications are often nonuniform, and thus their contribution towards the total cluster resource cost is often nonuniform. Some applications can also have footprints across multiple clusters. This can pose a challenge when performing cost attribution and cost management.
16
+
An Azure Kubernetes Service (AKS) cluster is reliant on Azure resources like virtual machines, virtual disks, load-balancers, and public IP addresses. Multiple applications can use these resources, which might be maintained by different teams within your organization. Resource consumption patterns for those applications are often variable, so their contribution towards the total cluster resource cost can also vary. Some applications can also have footprints across multiple clusters, which can pose a challenge when performing cost attribution and cost management.
17
17
18
18
Previously, [Microsoft Cost Management (MCM)](../cost-management-billing/cost-management-billing-overview.md) aggregated cluster resource consumption under the cluster resource group. You could use MCM to analyze costs, but there were several challenges:
19
19
20
-
*Costs were reported per cluster. There was no breakdown into discrete categories such as compute (including CPU cores and memory), storage, and networking.
20
+
*There was no Azure-native capability to display cluster resource usage at a level more granular than a cluster. There was no breakdown into discrete categories such as compute (including CPU cores and memory), storage, and networking.
21
21
22
-
* There was no Azure-native functionality to distinguish between types of costs. For example, individual application versus shared costs. MCM reported the cost of resources, but there was no insight into how much of the resource cost was used to run individual applications, reserved for system processes required by the cluster, or idle cost associated with the cluster.
23
-
24
-
* There was no Azure-native capability to display cluster resource usage at a level more granular than a cluster.
22
+
* There was no Azure-native functionality to distinguish between types of costs, for example between individual application costs and shared costs. MCM reported the cost of resources, but there was no insight into how much of the resource cost was used to run individual applications, how much was reserved for system processes required by the cluster, or what were the idle costs associated with the cluster.
25
23
26
24
* There was no Azure-native mechanism to analyze costs across multiple clusters in the same subscription scope.
27
25
28
-
As a result, you might have used third-party solutions, like Kubecost or OpenCost, to gather and analyze resource consumption and costs by Kubernetes-specific levels of granularity, such as by namespace or pod. Third-party solutions, however, require effort to deploy, fine-tune, and maintain for each AKS cluster. In some cases, you even need to pay for advance features, increasing the cluster's total cost of ownership.
29
-
30
-
To address this challenge, AKS has integrated with MCM to offer detailed cost drill down scoped to Kubernetes constructs, such as cluster and namespace, in addition to Azure Compute, Network, and Storage categories.
26
+
As a result, you might have used third-party solutions to gather and analyze resource consumption and costs by Kubernetes-specific levels of granularity, such as by namespace or pod. Third-party solutions, however, require effort to deploy, fine-tune, and maintain for each AKS cluster. In some cases, you even need to pay for advanced features, increasing the cluster's total cost of ownership.
31
27
32
-
The AKS cost analysis addon is built on top of [OpenCost](https://www.opencost.io/), an open-source Cloud Native Computing Foundation Sandbox project for usage data collection, which gets reconciled with your Azure invoice data. Post-processed data is visible directly in the [MCM Cost Analysis portal experience](/azure/cost-management-billing/costs/quick-acm-cost-analysis).
28
+
To address this challenge, AKS has integrated with MCM to offer detailed cost drill-down scoped to Kubernetes constructs, such as cluster and namespace, in addition to Azure Compute, Network, and Storage categories.
33
29
34
-
[!INCLUDE [preview features callout](./includes/preview/preview-callout.md)]
30
+
The AKS cost analysis addon is built on top of [OpenCost](https://www.opencost.io/), an open-source Cloud Native Computing Foundation Sandbox project for usage data collection. The cost analysis is reconciled with your Azure invoice data. Post-processed data is visible directly in the [MCM Cost Analysis portal experience](/azure/cost-management-billing/costs/quick-acm-cost-analysis).
35
31
36
32
## Prerequisites and limitations
37
33
38
34
* Your cluster must be either `Standard` or `Premium` tier, not the `Free` tier.
39
35
40
36
* To view cost analysis information, you must have one of the following roles on the subscription hosting the cluster: Owner, Contributor, Reader, Cost management contributor, or Cost management reader.
41
37
42
-
* Once cost analysis has been enabled, you can't downgrade your cluster to the `Free` tier without first disabling cost analysis.
38
+
* Once you have enabled cost analysis, you can't downgrade your cluster to the `Free` tier without first disabling cost analysis.
43
39
44
40
* Your cluster must be deployed with a [Microsoft Entra Workload ID](./workload-identity-overview.md) configured.
45
41
46
42
* If using the Azure CLI, you must have version `2.44.0` or later installed, and the `aks-preview` Azure CLI extension version `0.5.155` or later installed.
47
43
48
-
* The `ClusterCostAnalysis` feature flag must be registered on your subscription.
49
-
50
44
* Kubernetes cost views are available only for the following Microsoft Azure Offer types. For more information on offer types, see [Supported Microsoft Azure offers](/azure/cost-management-billing/costs/understand-cost-mgt-data#supported-microsoft-azure-offers).
51
45
* Enterprise Agreement
52
46
* Microsoft Customer Agreement
53
47
48
+
* Virtual nodes aren't supported at this time.
49
+
54
50
55
51
### Install or update the `aks-preview` Azure CLI extension
56
52
@@ -66,31 +62,11 @@ If you need to update the extension version, you can do this using the [`az exte
66
62
az extension update --name aks-preview
67
63
```
68
64
69
-
### Register the 'ClusterCostAnalysis' feature flag
70
-
71
-
Register the `ClusterCostAnalysis` feature flag by using the [az feature register][az-feature-register] command, as shown in the following example:
72
-
73
-
```azurecli-interactive
74
-
az feature register --namespace "Microsoft.ContainerService" --name "ClusterCostAnalysis"
75
-
```
76
-
77
-
It takes a few minutes for the status to show *Registered*. Verify the registration status by using the [az feature show][az-feature-show] command:
78
-
79
-
```azurecli-interactive
80
-
az feature show --namespace "Microsoft.ContainerService" --name "ClusterCostAnalysis"
81
-
```
82
-
83
-
When the status reflects *Registered*, refresh the registration of the *Microsoft.ContainerService* resource provider by using the [az provider register][az-provider-register] command:
84
-
85
-
```azurecli-interactive
86
-
az provider register --namespace Microsoft.ContainerService
87
-
```
88
-
89
65
## Enable cost analysis on your AKS cluster
90
66
91
67
Cost analysis can be enabled during one of the following operations:
92
68
93
-
* Create a `Standard` or `Premium` tier AKS cluster
69
+
* Create a `Standard` or `Premium` tier AKS cluster.
94
70
95
71
* Update an AKS cluster that is already in `Standard` or `Premium` tier.
96
72
@@ -100,12 +76,15 @@ Cost analysis can be enabled during one of the following operations:
100
76
101
77
* Downgrade a `Premium` cluster to `Standard` tier.
102
78
103
-
To enable the feature, use the flag `--enable-cost-analysis` in combination with one of these operations. For example, the following command will create a new AKS cluster in the `Standard` tier with cost analysis enabled:
79
+
To enable the feature, use the flag `--enable-cost-analysis` in combination with one of these operations. For example, the following command creates a new AKS cluster in the `Standard` tier with cost analysis enabled:
104
80
105
81
```azurecli-interactive
106
82
az aks create --resource-group <resource_group> --name <name> --location <location> --enable-managed-identity --generate-ssh-keys --tier standard --enable-cost-analysis
107
83
```
108
84
85
+
> [!WARNING]
86
+
> The AKS cost analysis addon Memory usage is dependent on the number of containers deployed. Memory consumption can be roughly approximated by 200MB + 0.5MB per Container. The current memory limit is set to 4GB which will support approximately 7000 containers per cluster but could be more or less depending on various factors. These estimates are subject to change.
87
+
109
88
## Disable cost analysis
110
89
111
90
You can disable cost analysis at any time using `az aks update`.
@@ -117,19 +96,30 @@ az aks update --name myAKSCluster --resource-group myResourceGroup --disable-cos
117
96
> [!NOTE]
118
97
> If you intend to downgrade your cluster from the `Standard` or `Premium` tiers to the `Free` tier while cost analysis is enabled, you must first explicitly disable cost analysis as shown here.
119
98
120
-
## View cost information
99
+
## View the cost data
121
100
122
-
You can view cost allocation data in the Azure portal. To learn more about how to navigate the cost analysis UI view, see the [Cost Management documentation](/azure/cost-management-billing/costs/view-kubernetes-costs).
101
+
You can view cost allocation data in the Azure portal. To learn more about how to navigate the cost analysis UI view, see the [Cost Management documentation](/azure/cost-management-billing/costs/view-kubernetes-costs).
102
+
103
+
### Cost definitions
104
+
105
+
In the Kubernetes namespaces and assets views you'll see the following charges:
106
+
107
+
-**Idle charges**: Represents the cost of available resource capacity that wasn't used by any workloads.
108
+
-**Service charges**: Represents the charges associated with the service like Uptime SLA, Microsoft Defender for Containers etc.
109
+
-**System charges**: Represents the cost of capacity reserved by AKS on each node to run system processes required by the cluster, including the kubelet and container runtime. [Learn more](./concepts-clusters-workloads.md#resource-reservations).
110
+
-**Unallocated charges**: Represents the cost of resources that couldn't be allocated to namespaces.
123
111
124
112
> [!NOTE]
125
-
> It might take up to one day for data to finalize
113
+
> It might take up to one day for data to finalize. After 24 hours, any fluctuations in costs for the previous day will have stabilized.
126
114
127
115
## Troubleshooting
128
116
129
117
See the following guide to troubleshoot [AKS cost analysis add-on issues](/troubleshoot/azure/azure-kubernetes/aks-cost-analysis-add-on-issues).
Visibility is one element of cost management. Refer to [Optimize Costs in Azure Kubernetes Service (AKS)](./best-practices-cost.md) for other best practices on how to gain control over your kubernetes cost.
0 commit comments