The cost insights feature of Container Service for Kubernetes (ACK) helps the finance department analyze resource usage and allocate costs from multiple dimensions. This feature also offers suggestions on cost savings.
Prerequisites
An ACK cluster that runs Kubernetes 1.18.8 or later is ready. To upgrade the Kubernetes version, see Manually upgrade a cluster.
Managed Service for Prometheus is enabled in the cluster. For more information, see Enable Prometheus monitoring.
Billing
Cost insights metrics
The cost insights feature generates basic metrics from data such as bills and cloud resource pricing, and reports them to Managed Service for Prometheus. Modifying default configurations, such as storage retention periods, may incur additional costs.
Cost tag configuration By default, the cost insights feature filters data using cost allocation tags. To ensure Cost Insights can retrieve billing data or node pool analytics:
Enable Cost allocation tags in the Expenses and Costs console.
Enable the
ack.aliyun.comandack.alibabacloud.com/nodepool-idtags in the Cost allocation tags settings.
Enable cost insights
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, find the cluster you want and click its name. In the left-side pane, choose .
Assign the AliyunCSManagedCostRole Resource Access Management (RAM) role to your cluster and install the ack-cost-exporter component.
Authorize your ACK cluster to access your billing data in Billing Management
ACK managed clusters: The system automatically grants the required permissions. After the authorization is complete, the system automatically creates the AliyunCSManagedCostRole role. Managed Service for Prometheus assumes the RAM role to access your billing data in Expenses and Costs.
You can also Authorize on the RAM Quick Authorization page.
ACK dedicated clusters:
Install the ack-cost-exporter component
Follow the on-screen instructions to install the ack-cost-exporter component. After the component is installed, you are automatically redirected to the Cost Insights page.
Disable cost insights
If you do not need to use the cost insights feature, you can uninstall the ack-cost-exporter component and disable the feature.
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, find the one you want to manage and click its name. In the left navigation pane, click Add-ons.
On the Add-ons page, find ack-cost-exporter and click Uninstall. In the Uninstall message, click OK.
FAQ
What do I do if I fail to install or uninstall the ack-cost-exporter component?
If you fail to install ack-cost-exporter, run the following commands to delete the resources related to ack-cost-exporter. Then, install ack-cost-exporter again. For more information about how to install ack-cost-exporter, see Manage components.
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 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 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 you fail to uninstall ack-cost-exporter, run the following commands to delete the resources related to ack-cost-exporter.
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 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 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