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 steps below to enable KubeSphere Billing.
Edit the ConfigMap
kubesphere-config
by running the following command:kubectl edit cm kubesphere-config -n kubesphere-system
Add the retention day and price information under
metering
in the ConfigMap.Parameter Description retentionDay
retentionDay
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 ofretention
in Prometheus.currencyUnit
The currency that displays on the Metering and Billing page. Currently allowed values are CNY
(Renminbi) andUSD
(US dollars). If you specify other currencies, the console will display cost in USD by default.cpuPerCorePerHour
The unit price of CPU per core/hour. memPerGigabytesPerHour
The unit price of memory per GB/hour. ingressNetworkTrafficPerMegabytesPerHour
The unit price of ingress traffic per MB/hour. egressNetworkTrafficPerMegabytesPerHour
The unit price of egress traffic per MB/hour. pvcPerGigabytesPerHour
The 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. 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
...
After you set the price information, restart
ks-apiserver
.kubectl rollout restart deploy ks-apiserver -n kubesphere-system
On the Metering and Billing page, you can see the cost information of resources.
当前内容版权归 KubeSphere 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 KubeSphere .