Kubernetes - How Finout Calculates K8s Costs
The cost of a Kubernetes (K8s) pod can vary depending on various factors, such as the size of the pod, the resources allocated to it, the duration of its usage, and the cloud provider or infrastructure used to run the pod. To accurately calculate the cost of a K8s pod, it is essential to consider the resources consumed by the pod, including CPU, memory, storage, and network bandwidth. The cost of these resources may differ depending on the cloud provider or infrastructure used.
Step 1: Query the Metrics
Finout provides multiple ways to integrate your K8s clusters with MegaBill, including Datadog or with a cronjob that queries your Prometheus. Metrics are gathered from the source frequently, including CPU usage, memory usage, CPU request, memory request, and network usage.
Step 2: Parse the Usage Metrics Per Pod
Once the data is received, it is processed to determine how much of the allocated resources the pod has used per hour. The usage metrics are processed as follows:
Memory and CPU: This is done by identifying the maximum value of either the usage or request during the hour. For example, if the maximum request during the hour is 3 CPU units and the maximum usage is 1 CPU unit, the cost is based on 3 CPU units. If during the hour, the usage was 4 CPU units, the cost is based on 4 CPU units This is calculated for both CPU and memory for each hour and each pod.
Network usage: Finout calculates the total number of bytes per pod (both received and transmitted) per hour.
Step 3: Get the Hourly Rate Per Cloud VM (Node)
One of the unique features of Finout is that your cost data is fetched from all major cloud vendors. Finout can consume, for example, the AWS Cost and Usage Report (CUR) and determine the exact cost of a single node, accounting for special pricing and discounts, such as Saving Plans, Reserved Instances (RIs), Spot Instances and if needed your EDP. This allows Finout to calculate the hourly node cost accurately.
Step 4: Calculate the Pod Costs
To calculate the cost of a pod, Finout uses the hourly CPU, memory, and network allocations (step 2), along with the hourly node cost (step 3), to determine the pod's CPU and memory cost, respectively.
CPU & memory
The hourly node cost is reported as a total cost and represents the cost for CPU and memory resources. The problem is that the cloud provider does not provide a CPU/memory breakdown. To apportion the costs to CPU and memory costs correctly, Finout specifies a configurable CPU/memory ratio for each resource, cluster or namespace.
The following formulas are used for calculating the cost of CPU and memory within the node, which are used to derive this ratio:
Old Ratio
The old 50:50 CPU-to-memory ratio for existing accounts is being enhanced to provide better accuracy in cost distribution. This balanced split was ideal for average workloads but could result in inaccurate financial reporting when actual resource configurations differ.
The CPU/Memory pricing of the old ratio is calculated using the following formulas:
1. Hourly Pod Price - This refers to the cost of the pod per hour, which is the total price without distinguishing between memory and CPU usage. The following formulas are used for calculating the cost of CPU and memory within the node, which are used to derive this ratio.

2. Hourly Pod CPU Allocation- Hourly pod CPU allocation is used to determine how much of the node’s CPU was allocated. Its based on the greater value of the average hourly CPU usage or the average hourly CPU request. See the full explanation about parsing the metrics per pod in step 2.

3. Hourly Pod CPU Price - Calculate the CPU cost by applying the CPU allocation ratio to the node’s total cost, adjusted for the node’s active time. This calculation is based on the hourly pod CPU allocation derived in the previous formula.

4. Hourly Pod Memory Allocation- Hourly pod memory allocation shows how much of the node’s memory was allocated. It is calculated as the greater value of the average hourly memory usage or the average hourly memory requests. See the full explanation about parsing the metrics per pod in step 2.

5. Hourly Pod Memory Price - Calculates the Memory cost out of the total node cost, using the allocation ratio, considering the actual time the node was active and in use. This calculation is based on the hourly pod memory calculation derived in the previous formula.

Refined Ratio
Finout offers an 88% CPU and 12% memory ratio for more precise cost allocation, reflecting real-world usage where CPU is usually more expensive than memory.
The pod's CPU/Memory hourly pricing using the refined ratio is calculated using the following formulas:
Hourly Pod Cost: Hourly Pod Cost is calculated by multiplying the number of allocated CPUs by the hourly CPU cost, as well as the amount of allocated memory by the hourly memory cost, and then adding these two results.
Hourly Pod CPU Allocation: Hourly pod CPU allocation is used to determine how much of the node’s CPU was allocated. This is based on the greater value of the average hourly CPU usage or the average hourly CPU request.See the full explanation about parsing the metrics per pod in step 2.
Hourly Pod CPU Cost: Calculates the cost of a single CPU unit per hour per pod.
Instance Price Per Hour = the hourly price of the node. This data is taken from step 3.
CPU Count = number of cores within the node
CPU Ratio = 88% by default
RAM (GiB) = the number of GiBs within the node
Memory Ratio = 12% by default
Hourly Pod Memory Allocation: Hourly Pod Memory Allocation is used to determine how much of the node’s CPU was allocated. It is based on the greater value of the average hourly CPU usage or the average hourly CPU request. See the full explanation about parsing the metrics per pod in step 2.
Hourly Pod Memory Cost: Calculates the cost of a single Memory unit per hour per pod.
Instance Price Per Hour = the hourly price of the node. This data is taken from step 3.
CPU Count = number of cores within the node
CPU Ratio = 88% by default
RAM (GiB) = the number of GiBs within the node
Memory Ratio = 12% by default
Network cost
For each node, Finout can calculate the data transfer hourly cost, based on the information supplied by the cloud provider. To calculate the network cost for each pod, Finout uses the network received and network transmitted metrics per pod and divides the cost of the node up into the pods based on these network metrics.
Step 5: Calculate the Node-Level Waste (Unallocated)
The unallocated cost at the node level is also calculated, which is the difference between the hourly node cost and the sum of hourly pod costs running on that node. This helps identify any unallocated costs associated with idle or underutilized nodes.
With Finout's comprehensive cost calculation and reporting capabilities, you can gain better visibility into the cost of running K8s pods and optimize your cloud costs effectively. Our CostGuard dashboards provide valuable insights to help you make informed decisions and implement cost optimization efforts for your K8s workloads. Idle Node Cost The idle cost of a node represents the portion of the node's cost that is not allocated to any pod. It is calculated as the difference between the total reported node cost from the billing data and the sum of all pod costs running on that node, as calculated by Finout. This unallocated cost helps identify underutilized capacity and can be used to optimize resource efficiency.
Last updated
Was this helpful?