Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubectl get hpa targets:unknow

I have installed kubeadm. Heapster show me metrics, but hpa no

kubectl get hpa

NAME      REFERENCE          TARGETS          MINPODS   MAXPODS   REPLICAS   AGE

httpd     Deployment/httpd   <unknown> / 2%   2         5         2          19m

kubeadm version

kubeadm version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.6", GitCommit:"7fa1c1756d8bc963f1a389f4a6937dc71f08ada2", GitTreeState:"clean", BuildDate:"2017-06-16T18:21:54Z", GoVersion:"go1.7.6", Compiler:"gc", Platform:"linux/amd64"}

docker version

Client:

Version:      1.11.2
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   b9f10c9
 Built:        Wed Jun  1 22:00:43 2016
 OS/Arch:      linux/amd64
like image 685
user2698993 Avatar asked Jun 24 '17 11:06

user2698993


People also ask

Does HPA need metrics server?

In order to work, HPA needs a metrics server available in your cluster to scrape required metrics, such as CPU and memory utilization. One straightforward option is the Kubernetes Metrics Server.


2 Answers

You may have had to enable a metrics-server. Heapster is now deprecated. Also make sure you have Kubernetes version greater than 1.7. You can check this buy typing kubectl get nodes.

You can enable the metrics server by looking at the minikube addons.

minikube addons list gives you the list of addons.

minikube addons enable metrics-server enables metrics-server.

Wait a few minutes, then if you type kubectl get hpa the percentage for the TARGETS <unknown> should appear.

like image 132
Paulina Avatar answered Sep 25 '22 08:09

Paulina


I found the solution:

kubectl describe hpa

failed to get cpu utilization: missing request for cpu on container httpd in pod default/httpd-796666570-2h1c6

Change the yaml of deployment and add:

resources:
  requests:
    cpu:400m

Then kubectl describe hpa

failed to get cpu utilization: unable to get metrics for resource cpu: no metrics returned from heapster

Wait a few minutes and all works fine.

like image 36
user2698993 Avatar answered Sep 22 '22 08:09

user2698993