Enable Billing

This tutorial demonstrates how to enable KubeSphere Billing to view the cost of different resources in your cluster. By default, the Billing function is disabled so you need to manually add the price information in a ConfigMap.

Perform the following steps to enable KubeSphere Billing.

  1. Run the following command to edit the ConfigMap kubesphere-config:

    kubectl edit cm kubesphere-config -n kubesphere-system
    
  2. Add the retention day and price information under metering in the ConfigMap. The following is an example for your reference:

    $ kubectl get cm kubesphere-config -n kubesphere-system -oyaml
    ...
        alerting:
          prometheusEndpoint: http://prometheus-operated.kubesphere-monitoring-system.svc:9090
          thanosRulerEndpoint: http://thanos-ruler-operated.kubesphere-monitoring-system.svc:10902
          thanosRuleResourceLabels: thanosruler=thanos-ruler,role=thanos-alerting-rules
        ...
        metering:
          retentionDay: 7d
          billing:
            priceInfo:
              currencyUnit: "USD"
              cpuPerCorePerHour: 1.5
              memPerGigabytesPerHour: 5
              ingressNetworkTrafficPerMegabytesPerHour: 1
              egressNetworkTrafficPerMegabytesPerHour: 1
              pvcPerGigabytesPerHour: 2.1
    kind: ConfigMap
    ...
    

    The following table describes the parameters.

    ParameterDescription
    retentionDayretentionDay determines the date range displayed on the Metering and Billing page for users. The value of this parameter must be the same as the value of retention in Prometheus.
    currencyUnitThe currency that is displayed on the Metering and Billing page. Currently allowed values are CNY (Renminbi) and USD (US dollars). If you specify other currencies, the console will display cost in USD by default.
    cpuCorePerHourThe unit price of CPU per core/hour.
    memPerGigabytesPerHourThe unit price of memory per GB/hour.
    ingressNetworkTrafficPerMegabytesPerHourThe unit price of ingress traffic per MB/hour.
    egressNetworkTrafficPerMegabytesPerHourThe unit price of egress traffic per MB/hour.
    pvcPerGigabytesPerHourThe unit price of PVC per GB/hour. Note that KubeSphere calculates the total cost of volumes based on the storage capacity PVCs request regardless of the actual storage in use.
  3. Run the following command to restart ks-apiserver:

    kubectl rollout restart deploy ks-apiserver -n kubesphere-system
    
  4. On the Metering and Billing page, you can see the cost information of resources.

Receive the latest news, articles and updates from KubeSphere


Thanks for the feedback. If you have a specific question about how to use KubeSphere, ask it on Slack. Open an issue in the GitHub repo if you want to report a problem or suggest an improvement.

What’s on this Page