kubecost / kubectl-cost

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

New vertical format for predict #144

Closed michaelmdresser closed 1 year ago

michaelmdresser commented 1 year ago

What does this PR change?

Note verticality is a little excessive when object names wrap. See https://github.com/jedib0t/go-pretty/issues/261.

Does this PR rely on any other PRs?

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

Overhauled kubectl cost predict formatting to use less horizontal space while adding more data: resource amounts, resource prices, and % cost change.

How was this PR tested?

$ go run cmd/kubectl-cost/kubectl-cost.go predict -r michaelkc -f ./test/multi.yaml

 OBJECT                        Δ QTY  RESOURCE UNIT   COST PER UNIT     Δ COST/MO  % CHANGE 
────────────────────────────────────────────────────────────────────────────────────────────
 michaelkc deployment             +9  CPU cores           23.27 USD   +209.47 USD           
 nginx-deployment                                                                           
                                  +6  RAM GiB              3.12 USD    +18.72 USD           

────────────────────────────────────────────────────────────────────────────────────────────
 kubecost deployment             +15  CPU millicores      0.023 USD     +0.35 USD           
 kubecost-cost-analyzer                                                                     
                                  +9  RAM MiB            0.0030 USD     +0.03 USD           

────────────────────────────────────────────────────────────────────────────────────────────
 michaelkc deployment            -92  CPU millicores      0.023 USD     -2.14 USD   -92.00% 
 michaelkc-cost-analyzer                                                                    
                             -172.65  RAM MiB            0.0030 USD     -0.53 USD   -43.38% 

────────────────────────────────────────────────────────────────────────────────────────────
 michaelkc deployment            +10  CPU cores           23.27 USD   +232.74 USD           
 nginx-deployment-2                                                                         
                                 +35  RAM GiB              3.12 USD   +109.17 USD           

                                  +5  GPUs               693.50 USD  +3467.50 USD           

────────────────────────────────────────────────────────────────────────────────────────────
 michaelkc pod nginx-pod        +350  CPU millicores      0.023 USD     +8.15 USD           
                                +200  RAM MiB            0.0030 USD     +0.61 USD           
                            ────────────────────────────────────────────────────────────────
                                +350  CPU millicores      0.023 USD     +8.15 USD           
                                +200  RAM MiB            0.0030 USD     +0.61 USD           
                                  +3  GPUs               693.50 USD  +2080.50 USD           
────────────────────────────────────────────────────────────────────────────────────────────
 TOTAL MONTHLY COST CHANGE                                           +6133.32 USD  

Have you made an update to documentation?

See README updates