The cost insights feature of Container Service for Kubernetes (ACK) helps you analyze resource usage and allocate costs across namespaces, node pools, and applications. It also identifies savings opportunities based on your cluster spending.
Cost dimensions
After you enable cost insights, you can analyze costs by:
Cluster
Namespace
Node pool
Application (Deployment, StatefulSet, DaemonSet, Job, CronJob)
Prerequisites
Before you begin, make sure that you have:
An ACK managed or dedicated cluster running Kubernetes 1.18.8 or later. To upgrade, see Manually upgrade a cluster
Managed Service for Prometheus enabled in the cluster. For setup instructions, see Enable Prometheus monitoring
Billing
Cost insights metrics
Cost insights generates metrics from your billing data and cloud resource pricing, then reports them to Managed Service for Prometheus. Changing default settings such as storage retention periods may incur additional costs.
Cost allocation tags
Cost insights uses cost allocation tags to filter billing data and correlate it with node pool analytics. Configure these tags before you enable the feature:
Go to the Expenses and Costs console.
On the Cost allocation tags page, select the tags you want to enable from the left panel, move them to the Selected Tags area, and click Enable.
Enable the following tags:
ack.aliyun.comack.alibabacloud.com/nodepool-id
Enable cost insights
Log on to the Container Service Management Console . In the navigation pane on the left, click Clusters.
On the Clusters page, click the name of your cluster. In the navigation pane on the left, click .
Authorize your cluster to access billing data.
The authorization process differs by cluster type:
Grant permission to access billing data
ACK managed clusters
The system automatically grants the required permissions and creates the AliyunCSManagedCostRole Resource Access Management (RAM) role. Managed Service for Prometheus assumes this role to access your billing data in Expenses and Costs.
Alternatively, authorize directly from the RAM Quick Authorization page.
ACK dedicated clusters
Manually add billing permissions to the worker role policy:
Install the ack-cost-exporter component by following the on-screen instructions.
After installation, the page redirects to Cost Insights automatically.
Disable cost insights
To stop collecting cost metrics, uninstall the ack-cost-exporter component:
Log on to the Container Service Management Console . In the navigation pane on the left, click Clusters.
On the Clusters page, click the name of your cluster. In the navigation pane on the left, click 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 the leftover resources manually, then retry the operation. Run the following commands against your cluster:
# 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-roleIf the install failed, reinstall ack-cost-exporter after cleaning up. For details, see Manage components.