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. This topic describes how to enable and disable the cost insights feature.

Prerequisites

Enable cost insights

  1. Log on to the ACK console and click Clusters in the left-side navigation pane.
  2. On the Clusters page, click the name of a cluster and choose Cost Management Suite > Cost Insights (Formerly Known as Cost Analysis) in the left-side navigation pane.
  3. Authorize your ACK cluster to access your bills in User Center.
    • If your cluster is an ACK managed cluster, click Cloud Resource Access Authorization. On the Cloud Resource Access Authorization page, click Agree to Authorization.

      After the authorization is complete, the system automatically creates a Resource Access Management (RAM) role named AliyunCSManagedCostRole. Prometheus Service assumes this RAM role to access your bills in User Center

    • If your cluster is an ACK dedicated cluster, perform the following operations to authorize your cluster to access your bills in User Center.
      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 Edit Basic 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.
  4. Return to the Cost Insights page and click Install to install the component. After the component is installed, click Upgrade.
    After the component is updated, the Cost Insights page appears.

Disable cost insights

To disable cost insights, uninstall the ack-cost-exporter component.

  1. Log on to the ACK console and click Clusters in the left-side navigation pane.
  2. On the Clusters page, click the name of a cluster and choose Operations > Add-ons in the left-side navigation pane.
  3. On the Add-ons page, find ack-cost-exporter and click Uninstall.
  4. 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 system components.
  • 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