Skip to content

kubecost cost cli predict fails on 2.2.x #172

@dazmc

Description

@dazmc

Kubecost Version

2.2.5

Kubernetes Version

1.28

Kubernetes Platform

EKS

Description

kubectl plugin for kubecost (aka cost) errors when executing predict subcommand.

EKS 1.28.8
kubecost UI Version 2.2.5 (c0726bff)
kubectl cost version info
Git Commit: d675760
Git Branch: HEAD
Git State: clean
Git Summary: v0.6.2
Build Date: 2024-03-19T16:32:10Z

if i use the yaml example here

read -r -d '' DEF << EndOfMessage
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  namespace: default
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        resources:
          requests:
            cpu: "3"
            memory: "2Gi"
EndOfMessage
echo "$DEF" | kubectl cost predict -f -

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 502 and data: <html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.25.5</center>
</body>
</html>

Steps to reproduce

  1. Deploy kubecost version 2.2.5
  2. Install cost plugin - kubectl krew install cost
  3. Use predict subcommand
read -r -d '' DEF << EndOfMessage
 apiVersion: apps/v1
 kind: Deployment
 metadata:
   name: nginx-deployment
   namespace: default
   labels:
     app: nginx
 spec:
   replicas: 3
   selector:
     matchLabels:
       app: nginx
   template:
     metadata:
       labels:
         app: nginx
     spec:
       containers:
       - name: nginx
         image: nginx:1.14.2
         resources:
           requests:
             cpu: "3"
             memory: "2Gi"
 EndOfMessage
 echo "$DEF" | kubectl cost predict -f -

Expected behavior

It should work

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

But it doesn't

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 502 and data: <html>
 <head><title>502 Bad Gateway</title></head>
 <body>
 <center><h1>502 Bad Gateway</h1></center>
 <hr><center>nginx/1.25.5</center>
 </body>
 </html>

Impact

We want to use kubectl cost predict subcommand as part of CI/CD process this hinders end to end benefit of kubecost. Monitoring and adjusting what has already been deployed works, but blocking it being created in the first place fails.

Using version 1.x is not a valid approach

Screenshots

No response

Logs

No response

Slack discussion

https://kubecost.slack.com/archives/CE76NJE6S/p1717166927611369?thread_ts=1717166927.611369&cid=CE76NJE6S

Troubleshooting

  • I have read and followed the issue guidelines and this is a bug impacting only the Kubecost application.
  • I have searched other issues in this repository and mine is not recorded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions