'How to get vertical pod autoscaling recommendations using kubernetes client-go package?

I am using the client-go to generate reports about resources for my team. We are using VPA(https://github.com/kubernetes/autoscaler) to compare its recommendations for pods against our own. I have everything working well except for the part where I get the recommendations from the Pod. In kubectl, I would enter the following to get descriptions of the pods in the namespace:

k describe vpa -n ABC

The description for each pod includes the following section:

Status:
  Conditions:
    Last Transition Time:  2022-02-09T10:33:28Z
    Status:                True
    Type:                  RecommendationProvided
  Recommendation:
    Container Recommendations:
      Container Name:  my-service
      Lower Bound:
        Cpu:     25m
        Memory:  442246463
      Target:
        Cpu:     25m
        Memory:  442809964
      Uncapped Target:
        Cpu:     25m
        Memory:  442809964
      Upper Bound:
        Cpu:     25m
        Memory:  724829578

I cannot figure out how to get this information using the go-client package. I am using another package, "k8s.io/metrics/pkg/client/clientset/versioned", to get current resource information for a pod.

I'd appreciate your suggestions... The only thing that I can think to do is to execute kubectl inside my golang app, capture the output, and go from there... Pretty hacky and not very scalable.

Thanks for your time and interest, Mike



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source