DEV Community

Tomoyuki KOYAMA
Tomoyuki KOYAMA

Posted on

HorizontalPodAutoscaler does not return TARGETS metrics and returns '<unknown>' on kubectl.

I had faced the error: HorizontalPodAutoscaler does not return TARGETS metrics and returns '<unknown>' on kubectl.

Image description

Environment

Kubrenetes engine: RKE2 (v1.22.6+rke2r1) x 3 nodes

Manifest: https://github.com/cdsl-research/text-checker/blob/c351a2ebe042560842913ca9501949fc90198252/kubernetes/scaleOut.yml

Solution

First, I tried to run the following command.

kubectl get --raw /apis/metrics.k8s.io/v1beta1"
Enter fullscreen mode Exit fullscreen mode

The command returns an error.

Second, I installed metrics-server to the cluster.

https://github.com/kubernetes-sigs/metrics-server

I retry to run kubectl get --raw /apis/metrics.k8s.io/v1beta1. The command runs successfully.

Third, I fixed kubernetes manifests as summarised below.

  • Set 'requests' parameter per container in deployment
  • Fix resource specs for HPA

https://github.com/cdsl-research/text-checker/commit/e13c178eaa4e1ab140462bf658a4e477f87babb1

https://github.com/cdsl-research/text-checker/commit/1bcc0dc21fc5f3fd8a7b42064e582e23cff303ab

Finally, the command 'kubectl get hpa' returns values 'TARGETS' successfully.

Image description

Top comments (0)