kubecost / kubectl-cost

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

Show Asset prices on kubectl #78

Open dwbrown2 opened 3 years ago

dwbrown2 commented 3 years ago

It would be really cool to support kubectl cost assets so you could see the fully cost of nodes, LBs, etc in your cluster! This is available in kubecost APIs we just need to expose to the CLI.

michaelmdresser commented 3 years ago

API reference: https://github.com/kubecost/docs/blob/master/assets.md#assets-api

Good idea. What do you think the columns of the table should be? Each asset type has different data worth displaying. Maybe we break it down further as kubectl cost assets TYPE? If we did that, we could also have kubectl cost assets just display total costs for each asset type.

dwbrown2 commented 3 years ago

My default would something similar to kubectl get nodes! So along the lines of the following:

NAME                                         STATUS   TYPE               AGE   MONTHLY COST
gke-new-kc-demo-default-pool-50db4258-2yg7   Ready    node:n1-standard   11d   $12.20
gke-new-kc-demo-default-pool-50db4258-5yga   Ready    node:n1-standard   11d   $12.20

What do you think? Might need to think more about applying this to other asset types, e.g. LBs...

michaelmdresser commented 3 years ago

Looks great. I think implementing this will also serve as an opportunity to refactor out the usage of /aggregatedCostModel in favor of /allocation if we can and tie commands a little more closely to the APIs they access. With that, adding more commands could become even easier.

michaelmdresser commented 3 years ago

For separately tracking the removal of /aggregatedCostModel: https://github.com/kubecost/kubectl-cost/issues/90

kaelanspatel commented 3 years ago

With v0.2.4 the node subcommand is live. We definitely want to expand on this; https://github.com/kubecost/kubectl-cost/pull/95 should make adding more assets relatively easy.

I think a variation of @michaelmdresser's idea above is good, where we have kubectl ASSET-TYPE subcommands like we have kubectl node, as well as a general kubectl assets which gives a holistic cost breakdown by each asset type as the assets.html?agg=type kubecost page does.