All Products
Search
Document Center

Container Service for Kubernetes:Enable cost insights

Last Updated:Mar 11, 2025

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

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:

    1. Enable Cost allocation tags in the Expenses and Costs console.

    2. Enable the ack.aliyun.com and ack.alibabacloud.com/nodepool-id tags in the Cost allocation tags settings.

Enable cost insights

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, find the cluster that you want to manage and click its name. In the left-side pane, choose Cost Suite > Cost Insights.

  3. Assign the AliyunCSManagedCostRole Resource Access Management (RAM) role to your cluster and install the ack-cost-exporter component.

    1. 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 click the Cloud Resource Access Authorization hyperlink. On the Cloud Resource Access Authorization page, click Agree to Authorization.

      • ACK dedicated clusters:

        Expand to view the steps for authorization

        1. On the Cost Insights page, click KubernetesWorkerRole-***.

        2. On the Permissions tab of the details page of the RAM role, click k8sWorkerRole**** in the Policy column.

        3. On the Policy Document tab of the policy details page, click Modify Policy Document.

        4. In the code editor that appears, add the following content to the Statement field, click Next to edit policy information, and then click OK.

                  {
                      "Action": [
                          "bssapi:QueryInstanceBill",
                          "bssapi:DescribeInstanceBill"
                      ],
                      "Resource": "*",
                      "Effect": "Allow"
                  },
                  {
                      "Action": [
                          "ecs:DescribeDisks",
                          "ecs:DescribeSpotPriceHistory",
                          "ecs:DescribeInstances",
                          "ecs:DescribePrice"
                      ],
                      "Resource": "*",
                      "Effect": "Allow"
                  },
                  {
                      "Action": [
                          "eci: DescribeContainerGroupPrice"
                      ],
                      "Resource": "*",
                      "Effect": "Allow"
                  }
          Note

          To specify multiple actions, add a comma (,) to the end of the content of each action before you enter the content of the next action.

    2. 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.

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, find the cluster that you want to manage and click its name. In the left-side navigation pane, choose Operations > Add-ons.

  3. 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-role
  • If 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