1

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

A Bit of Help
  • 1,368
  • 19
  • 36
  • Maybe you can use [k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned](https://pkg.go.dev/k8s.io/autoscaler/vertical-pod-autoscaler@v0.10.0/pkg/client/clientset/versioned#Clientset.AutoscalingV1) to access `VerticalPodAutoscaler.VerticalPodAutoscalerStatus`? – jaese Feb 11 '22 at 02:36
  • Thank you for the nudge in the right direction, Jaese! I've completed the application after digging through some of the autoscaler code. The following statement is what I used to build a client to access the info in my app. autoCLient, err := clientset.VerticalPodAutoscalers(namespace).Get(context.TODO(), vpaName, metav1.GetOptions{}) – A Bit of Help Feb 11 '22 at 11:39

0 Answers0