kubecost / kubectl-cost

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

predict method not allowed on 1.102 #153

Closed jessegoodier closed 1 year ago

jessegoodier commented 1 year ago

Not sure if this is user error or not, but:

k cost predict -f cpu-limit-eq-request.yaml --predict-speccost-path https://demo.kubecost.xyz/model/prediction/speccost

yields:

Error: Failed querying the speccost API. This API requires a version of Kubecost >= 1.101, which may be why this query failed. If running Kubecost v1.100, you can downgrade kubectl cost to v0.4 for old-style prediction. Error: failed to port forward query: received non-200 status code 405 and data: <html>
<head><title>405 Not Allowed</title></head>
<body>
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx/1.22.1</center>
</body>
</html>
dwbrown2 commented 1 year ago

@jessegoodier do you know what version of kubectl cost you're running?

@michaelmdresser @teevans for triage

jessegoodier commented 1 year ago

Update, this is not the way to use predict. Though there still seems to be an issue with predic. Is it my client?

this is correct, requires a proper context:

k cost predict -f memory-limit-eq-request.yaml

using kubectl v1.25.4

error:

k cost predict -f memory-limit-eq-request.yaml           
Error: Failed querying the speccost API. This API requires a version of Kubecost >= 1.101, which may be why this query failed. If running Kubecost v1.100, you can downgrade kubectl cost to v0.4 for old-style prediction. Error: failed to port forward query: received non-200 status code 500 and data: Failed to predict cost impact of specs: cannot predict impact of nil spec
jessegoodier commented 1 year ago

update: works on my test cluster, but not kc-demo-prod:

(arn:aws:eks:us-east-2:297945954695:cluster/test-1/jesse) ubuntu@aerog in /home/ubuntu
>k cost predict -f memory-limit-eq-request.yaml
 OBJECT                      Δ QTY  RESOURCE UNIT   COST PER UNIT  Δ COST/MO  % CHANGE
───────────────────────────────────────────────────────────────────────────────────────
 jesse deployment              +44  CPU millicores      0.023 USD  +1.01 USD
 memory-limit-eq-request
                               +44  RAM MiB            0.0030 USD  +0.13 USD

───────────────────────────────────────────────────────────────────────────────────────
 TOTAL MONTHLY COST                                                +1.14 USD

(arn:aws:eks:us-east-2:297945954695:cluster/test-1/jesse) ubuntu@aerog in /home/ubuntu
>kx kc-demo-prod
Switched to context "kc-demo-prod".

(kc-demo-prod/kubecost) ubuntu@aerog in /home/ubuntu
>k cost predict -f memory-limit-eq-request.yaml
Error: Failed querying the speccost API. This API requires a version of Kubecost >= 1.101, which may be why this query failed. If running Kubecost v1.100, you can downgrade kubectl cost to v0.4 for old-style prediction. Error: failed to port forward query: received non-200 status code 500 and data: Failed to predict cost impact of specs: cannot predict impact of nil spec
kc-creynold commented 1 year ago

some more info on what we are seeing:


kubectl config set-context --current --namespace=kubecost
Context "arn:aws:eks:us-west-2:297945954695:cluster/kc-demo-prod" modified.
$ chris@Christophers-MacBook-Pro  ~/src/se-demo/predict_samples   predict_samples_initial  kubectl cost predict -f small.yaml --log-level debug
2023-04-17T13:12:49.154625-04:00 DBG ServiceName set to: kubecost-cost-analyzer
2023-04-17T13:12:49.154746-04:00 DBG KubecostNamespace set to: kubecost
2023-04-17T13:12:50.177065-04:00 DBG checking readiness of 'kubecost-cost-analyzer-74d4f67bdf-qb2km'
2023-04-17T13:12:50.177091-04:00 DBG selected pod to forward: kubecost-cost-analyzer-74d4f67bdf-qb2km
2023-04-17T13:12:50.426228-04:00 DBG Port-forward set up at: http://localhost:58222/
2023-04-17T13:12:50.432428-04:00 DBG Executing GET to: http://localhost:58222/model/clusterInfo
2023-04-17T13:12:50.678468-04:00 DBG Cluster ID for query set to: kc-demo-prod
2023-04-17T13:12:50.678526-04:00 DBG Executing POST to: http://localhost:58222/model/prediction/speccost?clusterID=kc-demo-prod&defaultNamespace=kubecost&noUsage=false&windowAvgUsage=2d&windowResourceCost=7d+offset+48h
Error: Failed querying the speccost API. This API requires a version of Kubecost >= 1.101, which may be why this query failed. If running Kubecost v1.100, you can downgrade kubectl cost to v0.4 for old-style prediction. Error: failed to port forward query: received non-200 status code 500 and data: Failed to predict cost impact of specs: cannot predict impact o
```f nil spec
teevans commented 1 year ago

@michaelmdresser - Can you take a look here?

michaelmdresser commented 1 year ago

@kc-creynold @jessegoodier is this broken in nightly? We have a PR slated for release in 1.103 that should fix this: https://github.com/kubecost/kubecost-cost-model/pull/1383

jessegoodier commented 1 year ago

quick test works in nightly.

michaelmdresser commented 1 year ago

Closing as this should be fixed in v1.103 of Kubecost. If an error is still occurring, please reopen this issue.