skip to Main Content

I am using Kubernetes VPA as a resource recommender tool for my cluster and its generating the recommended specification for each deployment. But I would like to get a automated way to create the vpa recommendation to all the existing VPAs in a much readable format (preferred way is table format) dynamically.

I tried to create an Azure Devops pipeline and when parsing the json path from the kubectl get command I am not getting the resulted output.

k get  vpa myvpa -n mynamespace -o jsonpath='{status.recommendation.containerRecommendations.containerName[*]}'

2

Answers


  1. Chosen as BEST ANSWER

    This solved my requirement.

    kubectl get vpa -A -o json | jq -r '["Namespace", "AppName", "ContainerName", "LowerBoundCPU","LowerBoundMemmory", "upperBoundCPU", "upperBoundmemmory", "TargetCPU", "TargetMem"], (.items[] | [.metadata.namespace, .metadata.name] +(.status.recommendation.containerRecommendations[] | [.containerName, .lowerBound.cpu, .lowerBound.memory, .upperBound.cpu, .upperBound.memory, .target.cpu, .target.memory])) | @csv' >output.csv
    

  2. You might wanna fetch the VPAs with kubectl and pipe that into jq, something like

    $ k get vpa myvpa -n mynamespace -o json | jq ".items | @tsv"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search