I am using a kube config file to fetch the pod CPU and MEM data using go-lang. I am stuck to fetch the HPA details, i.e I am trying to write the equivalent of "kubectl get hpa", so I can know I have applied hpa to known services or not.
Any help on this is highly appreciated.
I have tried the below so far.
kubeClient "k8s.io/client-go/kubernetes/typed/autoscaling/v1"
hpaWatch, err := kubeClient.AutoscalingV1().HorizontalPodAutoscalers("default").Watch(metav1.ListOptions{})
But this is not working.
Here is the line you should have used:
and the following is a complete and working example for listing HPAs. You should be able just copy-paste it and run it.
It was tested with
[email protected]
.