kubecost / kubectl-cost

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

Predict command is not working through proxy #155

Closed rossfisherkc closed 6 months ago

rossfisherkc commented 1 year ago

Greetings,

I have a customer attempting to use this plugin with their deployment. They have setup a proxy for other users to access it. They also have SSO/SAML, but may not matter as they have the proxy set up

ZD issue link: https://kubecost.zendesk.com/agent/tickets/3893

It's not working for the predict command, see:

$ k cost predict -f /tmp/bla --use-proxy --log-level debug --server localhost:8080 
2023-04-21T22:00:13.75934787-03:00 ServiceName set to: kubecost-cost-analyzer 
2023-04-21T22:00:13.759386015-03:00 KubecostNamespace set to: kubecost 
Error: acquiring cluster ID from service: failed to proxy get kubecost. err: the server is currently unable to handle the request (get services kubecost-cost-analyzer:⎂); data: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"no endpoints available for service \"kubecost-cost-analyzer:⎂\"","reason":"ServiceUnavailable","code":503}`

While without proxy it works fine, like

OBJECT Δ QTY RESOURCE UNIT COST PER UNIT Δ COST/MO % CHANGE 
──────────────────────────────────────────────────────────────────────────────────────── 
default deployment +9 CPU cores 21.85 USD +196.63 USD 
nginx-deployment 
+6 RAM GiB 2.93 USD +17.59 USD 

──────────────────────────────────────────────────────────────────────────────────────── 
TOTAL MONTHLY COST +214.22 USD 

I'll share this issue with the customer to stay up to date

dwbrown2 commented 1 year ago

@michaelmdresser @kwombach12 thoughts on this one?

michaelmdresser commented 1 year ago

After reading the support ticket, I think we have a bit of a misunderstanding. kubectl cost cannot be pointed directly at a Kubecost API at the moment, which appears to be the user's wish (e.g. kubectl cost --some-flag-for-api-path "kcingress.example.com"). There is an outstanding issue on this repo for this request: https://github.com/kubecost/kubectl-cost/issues/128. I believe kubectl cost is working as intended, but this is certainly a shortcoming in functionality that we would like to address some day.


I recommend reading the README's section dedicated to the --use-proxy flag to understand what it does: https://github.com/kubecost/kubectl-cost#implementation-quirks.