All Products
Search
Document Center

Container Service for Kubernetes:Custom cost accounting policies

Last Updated:Mar 26, 2026

ACK cost insights supports custom cost accounting policies as an alternative to default cost allocation policies. If your internal pricing differs—for example, because your operations team resells bulk-purchased compute to business units at negotiated rates, or because you need to eliminate cost variations caused by scheduling—you can define custom pricing templates. Each template assigns unit prices for CPU and memory and is matched to Pods by label, namespace, and resource specification.

Note

Pod costs from custom pricing templates are available only through an API. After you configure custom pricing, retrieve the data from the customCost field in the API response. For more information, see Overview of retrieving cost data by API.

When to use custom pricing

Custom pricing templates are useful in the following scenarios:

  • An internal operations team purchases compute resources in bulk and resells them to business units at different rates.

  • Pods with identical specifications land on nodes of different specifications due to scheduling. You want to standardize costs at the business level and eliminate the resulting cost variation.

  • Business units deploy Pods with the same resource request but different overcommit ratios on the same node, and you need differentiated cost accounting based on the resource limit.

Prerequisites

Before you begin, make sure you have:

Step 1: Enable custom pricing in cost-exporter

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

  2. On the Clusters page, click the name of your cluster. In the left navigation pane, click Workloads > Deployments.

  3. At the top of the page, select kube-system from the Namespace drop-down list. Find the ack-cost-exporter Deployment. In the Actions column, choose More > View in YAML. In the command section, add '--enable-custom-price=true'. Click Update.

    image

Step 2: Configure a pricing template

  1. Create a file named price-template.yaml with the following content.

    Important

    All fields under spec are optional. A Pod matches a template when all configured spec fields match the Pod's metadata. A template with an empty spec matches all Pods. If a spec field is omitted, that condition is not applied and the template matches Pods regardless of that attribute.

    Templates are evaluated in order. When a Pod matches multiple templates, the system uses the first matching template from top to bottom.

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: price-template
      namespace: kube-system
    data:
      template.yaml: |
        - name: template-nginx
          spec:
            labelSelector:
              app: nginx
            namespaceSelector:
              - default
              - kube-system
            resource:
              cpu: 500m
              memory: 512Mi
              cpu-overcommit-ratio: 2
              memory-overcommit-ratio: 2
          price:
            cpu: 0.2
            memory: 0.03
        - name: template-default
          price:
            cpu: 0.1
            memory: 0.02

    This template defines two pricing rules:

    • template-nginx applies to Pods that meet all of the following conditions: the Pod has the app: nginx label, runs in the default or kube-system namespace, has a CPU resource request of 500m (limit: 1 Core), and has a memory resource request of 512 MiB (limit: 1 GiB).

    • template-default applies to all other Pods in the cluster.

    The following table describes the template parameters.

    Parameter Description
    name Name of the pricing template.
    spec.labelSelector Selector for matching Pod labels. Omit to match Pods with any label.
    spec.namespaceSelector List of namespaces to match. Omit to match Pods in any namespace.
    spec.resource.cpu CPU resource request of the Pod. Omit to match Pods with any CPU request.
    spec.resource.memory Memory resource request of the Pod. Omit to match Pods with any memory request.
    spec.resource.cpu-overcommit-ratio CPU overcommit ratio of the Pod, calculated as CPU resource limit / CPU resource request. Omit to match Pods with any CPU overcommit ratio.
    spec.resource.memory-overcommit-ratio Memory overcommit ratio of the Pod, calculated as memory resource limit / memory resource request. Omit to match Pods with any memory overcommit ratio.
    price.cpu Unit price of the Pod's CPU. Unit: Core-Hour.
    price.memory Unit price of the Pod's memory. Unit: GiB-Hour.
  2. Apply the ConfigMap to your cluster.

    kubectl apply -f price-template.yaml -n kube-system

What's next