Analyze resource usage and allocate costs by namespace, node pool, and application in ACK clusters.
Cost dimensions
You can analyze costs by:
-
Cluster
-
Namespace
-
Node pool
-
Application (Deployment, StatefulSet, DaemonSet, Job, CronJob)
Prerequisites
Make sure that you have:
-
An ACK managed or dedicated cluster running Kubernetes 1.18.8 or later. Upgrade the cluster if needed.
-
Managed Service for Prometheus enabled. See Enable Prometheus monitoring.
Billing
Cost insights metrics
Cost insights generates metrics from billing data and resource pricing, then reports them to Prometheus. Changing default settings such as storage retention periods may incur additional costs.
Cost allocation tags
Cost allocation tags filter billing data and correlate it with node pool analytics. Configure them before you enable cost insights:
-
Go to the Expenses and Costs console.
-
On the Cost allocation tags page, select tags from the left panel, move them to Selected Tags, and click Enable.
-
Enable these tags:
-
ack.aliyun.com -
ack.alibabacloud.com/nodepool-id
-
Enable cost insights
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, click the name of your cluster. In the left navigation pane, click .
-
Authorize your cluster to access billing data.
Authorization differs by cluster type:
-
Grant billing data access
-
ACK managed clusters
The system automatically creates the AliyunCSManagedCostRole RAM role. Prometheus assumes this role to access your billing data.
Or authorize from the RAM Quick Authorization page.
-
ACK dedicated clusters
Add billing permissions to the worker role policy:
-
-
Install ack-cost-exporter by following the on-screen instructions.
The page redirects to Cost Insights after installation.
-
Disable cost insights
To stop cost metric collection, uninstall ack-cost-exporter:
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, click the name of your cluster. In the left navigation pane, click Components and Add-ons.
-
On the Add-ons page, find ack-cost-exporter and click Uninstall. In the confirmation dialog, click OK.
FAQ
What do I do if ack-cost-exporter fails to install or uninstall?
Delete leftover resources manually, then retry:
# Delete the Deployment and Services
kubectl delete deployment ack-cost-exporter -n kube-system
kubectl delete service alibaba-cloud-price-exporter -n kube-system
kubectl delete service alibaba-cloud-billing-exporter -n kube-system
kubectl delete service alibaba-cloud-cost-exporter -n kube-system
# Delete ServiceMonitors
kubectl delete ServiceMonitor alibaba-cloud-price-exporter -n kube-system
kubectl delete ServiceMonitor alibaba-cloud-billing-exporter -n kube-system
kubectl delete ServiceMonitor alibaba-cloud-cost-exporter -n kube-system
# Delete RBAC resources
kubectl delete ClusterRoleBinding ack-cost-exporter-cluster-role-binding
kubectl delete ClusterRoleBinding ack-cost-exporter-cluster-role-binding-v1
kubectl delete ServiceAccount ack-cost-exporter -n kube-system
kubectl delete ClusterRole ack-cost-exporter-cluster-role
If installation failed, reinstall ack-cost-exporter after cleanup. See Manage components.