kubecost / kubectl-cost

CLI for determining the cost of Kubernetes workloads
Apache License 2.0
913 stars 60 forks source link

Remove /aggregatedCostModel dependency #93

Closed kaelanspatel closed 3 years ago

kaelanspatel commented 3 years ago

https://github.com/kubecost/kubectl-cost/issues/90

Tested locally and found numbers are slightly different now, but generally consistent with what the aggregated cost API used to return.

kaelanspatel commented 3 years ago

For reference: Before:

 kubectl cost namespace -A
+-------------+-----------+----------+----------+-------------+----------+----------+----------+-------------+--------------------+-----------------+
| NAMESPACE   | CPU       | CPU EFF. | MEMORY   | MEMORY EFF. | GPU      | PV       | NETWORK  | SHARED COST | MONTHLY RATE (ALL) | COST EFFICIENCY |
+-------------+-----------+----------+----------+-------------+----------+----------+----------+-------------+--------------------+-----------------+
| kube-system | 21.524469 | 0.058070 | 3.116918 | 0.291669    | 0.000000 | 0.000000 | 0.000000 | 0.000000    |          24.641386 |        0.087618 |
| kubecost    | 4.526266  | 0.052497 | 0.739329 | 1.878761    | 0.000000 | 2.269333 | 0.000000 | 0.000000    |          17.185883 |        0.308918 |
+-------------+-----------+----------+----------+-------------+----------+----------+----------+-------------+--------------------+-----------------+
| SUMMED      | 26.050735 |          | 3.856247 |             | 0.000000 | 2.269333 | 0.000000 | 0.000000    |      USD 41.827270 |                 |
+-------------+-----------+----------+----------+-------------+----------+----------+----------+-------------+--------------------+-----------------+

After:

kubectl cost namespace -A
+-------------+-------------+-----------+----------+-----------+-------------+----------+----------+----------+-------------+--------------------+------------------+-----------------+
| CLUSTER     | NAMESPACE   | CPU       | CPU EFF. | MEMORY    | MEMORY EFF. | GPU      | PV       | NETWORK  | SHARED COST | LOAD BALANCER COST | TOTAL COST (ALL) | COST EFFICIENCY |
+-------------+-------------+-----------+----------+-----------+-------------+----------+----------+----------+-------------+--------------------+------------------+-----------------+
| cluster-one | __idle__    | 33.807900 | 0.000000 | 28.088884 | 0.000000    | 0.000000 | 0.000000 | 0.000000 | 0.000000    | 0.000000           |        61.896784 |        0.000000 |
|             | kube-system | 23.948808 | 0.058070 | 3.467980  | 0.291669    | 0.000000 | 0.000000 | 0.000000 | 0.000000    | 0.000000           |        27.416788 |        0.087618 |
|             | kubecost    | 5.036057  | 0.052497 | 0.822594  | 1.878761    | 0.000000 | 0.000000 | 0.000000 | 0.000000    | 10.737950          |        16.596601 |        0.308916 |
+-------------+-------------+-----------+----------+-----------+-------------+----------+----------+----------+-------------+--------------------+------------------+-----------------+
| SUMMED      |             | 62.792765 |          | 32.379458 |             | 0.000000 | 0.000000 | 0.000000 | 0.000000    | 10.737950          |   USD 105.910173 |                 |
+-------------+-------------+-----------+----------+-----------+-------------+----------+----------+----------+-------------+--------------------+------------------+-----------------+

Note that PV cost doesn't work currently due to a problem in cost-model; I'll open an issue about this.