Concepts

TOC

Opencost

OpenCost is an open-source Kubernetes cost monitoring and management tool designed to track and analyze resource usage and costs in Kubernetes clusters in real time. It provides accurate resource metering data to help users optimize resource allocation and control costs.

For more information, please refer to the OpenCost official website.

Cost Model

A Cost Model defines the billing rules and pricing for resources within clusters. It includes:

  • Billing Items: Resources to be billed (CPU, Memory, Storage)
  • Billing Methods: How resources are measured and billed
  • Unit Prices: Base pricing for each resource type
  • Label-based Pricing: Differentiated pricing based on labels
  • Cluster Association: Which clusters the model applies to

Cost models help you define the resources and unit prices that need to be billed in clusters. The platform will measure and bill for each cluster based on the cost model.

Billing Method Description

Billing ItemBilling MethodBilling RulesDescription
CPUUsage (Core-hours)Calculated on an hourly basis using the POD's AVG(Usage) over the past hour, multiplied by the actual duration of the POD (counted as 5 minutes if less than 5 minutes).Based on actual CPU consumption
CPURequest (Core-hours)Calculated on an hourly basis using the POD's Request over the past hour, multiplied by the actual duration of the POD (counted as 5 minutes if less than 5 minutes).Based on CPU resource requests
CPUEffective Usage (Core-hours)Calculated on an hourly basis using the higher value of the POD's AVG(Usage) and Request over the past hour, multiplied by the actual duration of the POD (counted as 5 minutes if less than 5 minutes).Current default method, uses the higher of usage or request
CPUProject Quota (Core-hours)Calculated on an hourly basis using the project's allocated CPU quota limit, multiplied by time duration. Segmented calculation when quota changes.Based on project-level resource quotas
MemoryUsage (GiB-hours)Calculated on an hourly basis using the POD's AVG(Usage) over the past hour, multiplied by the actual duration of the POD (counted as 5 minutes if less than 5 minutes).Based on actual memory consumption
MemoryRequest (GiB-hours)Calculated on an hourly basis using the POD's Request over the past hour, multiplied by the actual duration of the POD (counted as 5 minutes if less than 5 minutes).Based on memory resource requests
MemoryEffective Usage (GiB-hours)Calculated on an hourly basis using the higher value of the POD's AVG(Usage) and Request over the past hour, multiplied by the actual duration of the POD (counted as 5 minutes if less than 5 minutes).Current default method, uses the higher of usage or request
MemoryProject Quota (GiB-hours)Calculated on an hourly basis using the project's allocated memory quota limit, multiplied by time duration. Segmented calculation when quota changes.Based on project-level resource quotas
StorageRequest Volume (GiB-hours)Calculated on an hourly basis using the Request size of the PV over the past hour, multiplied by the actual duration of the PV (counted as 5 minutes if less than 5 minutes). If a PV is simultaneously mounted to multiple PODs, the usage of the PV will be evenly distributed among each POD.PVs that are not mounted to any POD will be counted as unmounted records, with the object name being *unmounted-pvcs.

Current statistical issues will be addressed in future versions:

  • When a StatefulSet POD is stopped and restarted, the platform will use the earliest running time of the POD on that day as the start time and the latest running time as the end time, while ignoring the time in between when the POD was not running.