kubecost / kubectl-cost

CLI for determining the cost of Kubernetes workloads
Apache License 2.0
872 stars 55 forks source link

Switch 'kubectl cost predict' to use /prediction/speccost #143

Closed michaelmdresser closed 1 year ago

michaelmdresser commented 1 year ago

DO NOT RELEASE UNTIL v1.101 IS RELEASED

What does this PR change?

See release note.

I apologize to reviewers for the intense refactoring. Display options are now substantially clearer as a nice side effect, e.g. Allocation options no longer pollute Asset commands.

How does this PR impact users? (This is the kind of thing that goes in release notes!)

How was this PR tested?

→ go run cmd/kubectl-cost/kubectl-cost.go predict -r michaelkc -f ./test/multi.yaml              
+--------------------------------------------+------------+------------+-------------+-------------+
| WORKLOAD                                   | Δ CPU/MO   | Δ MEM/MO   | Δ GPU/MO    | Δ TOTAL/MO  |
+--------------------------------------------+------------+------------+-------------+-------------+
| michaelkc/deployment/nginx-deployment      | 209.47 USD |  18.72 USD |    0.00 USD |  228.18 USD |
| kubecost/deployment/kubecost-cost-analyzer |   0.35 USD |   0.03 USD |    0.00 USD |    0.38 USD |
| michaelkc/deployment/nginx-deployment-2    | 232.74 USD | 109.17 USD | 3467.50 USD | 3809.41 USD |
| michaelkc/pod/nginx-pod                    |   8.15 USD |   0.61 USD |    0.00 USD |    8.76 USD |
| michaelkc/pod/nginx-pod                    |   8.15 USD |   0.61 USD | 2080.50 USD | 2089.26 USD |
+--------------------------------------------+------------+------------+-------------+-------------+
|                                            | 458.85 USD | 129.13 USD | 5548.00 USD | 6135.98 USD |
+--------------------------------------------+------------+------------+-------------+-------------+
→ go run cmd/kubectl-cost/kubectl-cost.go predict -r michaelkc -f ./test/multi.yaml --only-after --only-diff=false
+--------------------------------------------+------------+------------+-------------+-------------+
| WORKLOAD                                   | CPU/MO     | MEM/MO     | GPU/MO      | TOTAL/MO    |
+--------------------------------------------+------------+------------+-------------+-------------+
| michaelkc/deployment/nginx-deployment      | 209.47 USD |  18.72 USD |    0.00 USD |  228.18 USD |
| kubecost/deployment/kubecost-cost-analyzer |   0.35 USD |   0.03 USD |    0.00 USD |    0.38 USD |
| michaelkc/deployment/nginx-deployment-2    | 232.74 USD | 109.17 USD | 3467.50 USD | 3809.41 USD |
| michaelkc/pod/nginx-pod                    |   8.15 USD |   0.61 USD |    0.00 USD |    8.76 USD |
| michaelkc/pod/nginx-pod                    |   8.15 USD |   0.61 USD | 2080.50 USD | 2089.26 USD |
+--------------------------------------------+------------+------------+-------------+-------------+
|                                            | 458.85 USD | 129.13 USD | 5548.00 USD | 6135.98 USD |
+--------------------------------------------+------------+------------+-------------+-------------+
→ go run cmd/kubectl-cost/kubectl-cost.go predict -r michaelkc -f ./test/multi.yaml --only-diff=false 
+--------------------------------------------+------------+------------+-------------+-------------+------------+------------+-------------+-------------+
| WORKLOAD                                   | CPU/MO     | MEM/MO     | GPU/MO      | TOTAL/MO    | Δ CPU/MO   | Δ MEM/MO   | Δ GPU/MO    | Δ TOTAL/MO  |
+--------------------------------------------+------------+------------+-------------+-------------+------------+------------+-------------+-------------+
| michaelkc/deployment/nginx-deployment      | 209.47 USD |  18.72 USD |    0.00 USD |  228.18 USD | 209.47 USD |  18.72 USD |    0.00 USD |  228.18 USD |
| kubecost/deployment/kubecost-cost-analyzer |   0.35 USD |   0.03 USD |    0.00 USD |    0.38 USD |   0.35 USD |   0.03 USD |    0.00 USD |    0.38 USD |
| michaelkc/deployment/nginx-deployment-2    | 232.74 USD | 109.17 USD | 3467.50 USD | 3809.41 USD | 232.74 USD | 109.17 USD | 3467.50 USD | 3809.41 USD |
| michaelkc/pod/nginx-pod                    |   8.15 USD |   0.61 USD |    0.00 USD |    8.76 USD |   8.15 USD |   0.61 USD |    0.00 USD |    8.76 USD |
| michaelkc/pod/nginx-pod                    |   8.15 USD |   0.61 USD | 2080.50 USD | 2089.26 USD |   8.15 USD |   0.61 USD | 2080.50 USD | 2089.26 USD |
+--------------------------------------------+------------+------------+-------------+-------------+------------+------------+-------------+-------------+
|                                            | 458.85 USD | 129.13 USD | 5548.00 USD | 6135.98 USD | 458.85 USD | 129.13 USD | 5548.00 USD | 6135.98 USD |
+--------------------------------------------+------------+------------+-------------+-------------+------------+------------+-------------+-------------+

Have you made an update to documentation?