Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option --available is not supported in combinaison with yaml or json output #92

Open
caparisi opened this issue Mar 9, 2023 · 0 comments

Comments

@caparisi
Copy link

caparisi commented Mar 9, 2023

Context

I try to catch the available request/limits resource in my cluster with a script to determine if I have enough resource to deploy new pod in my cluster. I want catch this information from a yaml or json output to easily manipulate the output with a jq or yq tool.

Actual results

The option -a is ignored when the output is not table

$ kube-capacity
NODE                              CPU REQUESTS   CPU LIMITS      MEMORY REQUESTS   MEMORY LIMITS
*                                 2939m (30%)    12744m (134%)   28368Mi (50%)     52476Mi (94%)
aks-default-xxxxxxx-vmss000000   1024m (53%)    9344m (491%)    2320Mi (43%)      10260Mi (191%)
aks-spot-yyyyyyyy-vmss000000      510m (26%)     850m (44%)      12224Mi (97%)     16266Mi (129%)
aks-spot-yyyyyyyy-vmss000018      485m (25%)     850m (44%)      5128Mi (40%)      9170Mi (72%)
aks-spot-yyyyyyyy-vmss00001g      460m (24%)     850m (44%)      4336Mi (34%)      8378Mi (66%)
aks-spot-yyyyyyyy-vmss00001t      460m (24%)     850m (44%)      4360Mi (34%)      8402Mi (66%)

$ kube-capacity -a
NODE                              CPU REQUESTS   CPU LIMITS     MEMORY REQUESTS   MEMORY LIMITS
*                                 6561m/9500m    -3244m/9500m   27387Mi/55755Mi   3279Mi/55755Mi
aks-default-xxxxxxx-vmss000000   876m/1900m     -7444m/1900m   3045Mi/5365Mi     -4895Mi/5365Mi
aks-spot-yyyyyyyy-vmss000000      1390m/1900m    1050m/1900m    374Mi/12598Mi     -3668Mi/12598Mi
aks-spot-yyyyyyyy-vmss000018      1415m/1900m    1050m/1900m    7470Mi/12598Mi    3428Mi/12598Mi
aks-spot-yyyyyyyy-vmss00001g      1440m/1900m    1050m/1900m    8262Mi/12598Mi    4220Mi/12598Mi
aks-spot-yyyyyyyy-vmss00001t      1440m/1900m    1050m/1900m    8238Mi/12598Mi    4196Mi/12598Mi

$ kube-capacity -a -o json 
{
  "nodes": [
    {
      "name": "aks-default-xxxxxxx-vmss000000",
      "cpu": {
        "requests": "1024m",
        "requestsPercent": "53%",
        "limits": "9344m",
        "limitsPercent": "491%"
      },
      "memory": {
        "requests": "2320Mi",
        "requestsPercent": "43%",
        "limits": "10260Mi",
        "limitsPercent": "191%"
      }
    },
    {
      "name": "aks-spot-yyyyyyyy-vmss000000",
      "cpu": {
        "requests": "510m",
        "requestsPercent": "26%",
        "limits": "850m",
        "limitsPercent": "44%"
      },
      "memory": {
        "requests": "12224Mi",
        "requestsPercent": "97%",
        "limits": "16266Mi",
        "limitsPercent": "129%"
      }
    },
    {
      "name": "aks-spot-yyyyyyyy-vmss000018",
      "cpu": {
        "requests": "485m",
        "requestsPercent": "25%",
        "limits": "850m",
        "limitsPercent": "44%"
      },
      "memory": {
        "requests": "5128Mi",
        "requestsPercent": "40%",
        "limits": "9170Mi",
        "limitsPercent": "72%"
      }
    },
    {
      "name": "aks-spot-yyyyyyyy-vmss00001g",
      "cpu": {
        "requests": "460m",
        "requestsPercent": "24%",
        "limits": "850m",
        "limitsPercent": "44%"
      },
      "memory": {
        "requests": "4336Mi",
        "requestsPercent": "34%",
        "limits": "8378Mi",
        "limitsPercent": "66%"
      }
    },
    {
      "name": "aks-spot-yyyyyyyy-vmss00001t",
      "cpu": {
        "requests": "460m",
        "requestsPercent": "24%",
        "limits": "850m",
        "limitsPercent": "44%"
      },
      "memory": {
        "requests": "4360Mi",
        "requestsPercent": "34%",
        "limits": "8402Mi",
        "limitsPercent": "66%"
      }
    }
  ],
  "clusterTotals": {
    "cpu": {
      "requests": "2939m",
      "requestsPercent": "30%",
      "limits": "12744m",
      "limitsPercent": "134%"
    },
    "memory": {
      "requests": "28368Mi",
      "requestsPercent": "50%",
      "limits": "52476Mi",
      "limitsPercent": "94%"
    }
  }
}

Expected results

When the -a is specify with a json or yaml output, remplace requests and limits (or add a field) by requestsAvailable and limitsAvailable

Version

$ kube-capacity version 
kube-capacity version v0.7.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant