13

I'm using Kubernetes 1.11 on Digital Ocean, when I try to use kubectl top node I get this error:

Error from server (NotFound): the server could not find the requested resource (get services http:heapster:)

but as stated in the doc, heapster is deprecated and no longer required from kubernetes 1.10

Rico
  • 58,485
  • 12
  • 111
  • 141
FakeAccount
  • 242
  • 1
  • 3
  • 19

2 Answers2

19

If you are running a newer version of Kubernetes and still receiving this error, there is probably a problem with your installation.

Please note that to install metrics server on kubernetes, you should first clone it by typing:

git clone https://github.com/kodekloudhub/kubernetes-metrics-server.git

then you should install it, WITHOUT GOING INTO THE CREATED FOLDER AND WITHOUT MENTIONING AN SPECIFIC YAML FILE , only via:

kubectl create -f kubernetes-metrics-server/

In this way all services and components are installed correctly and you can run:

kubectl top nodes

or

kubectl top pods

and get the correct result.

Farshid
  • 5,134
  • 9
  • 59
  • 87
13

For kubectl top node/pod to work you either need the heapster or the metrics server installed on your cluster.

Like the warning says: heapster is being deprecated so the recommended choice now is the metrics server.

So follow the directions here to install the metrics server

Rico
  • 58,485
  • 12
  • 111
  • 141
  • 2
    I installed metrics-server in the cluster in the kube-system namespace, but still getting the same error. if I do kubectl logs kubectl logs metrics-server-85dc785fbf-76qf9 I get this output `E1018 12:10:51.797774 1 manager.go:102] unable to fully collect metrics: [unable to fully scrape metrics from source kubelet_summary:nostalgic-pare-gt8: unable to fetch metrics from Kubelet nostalgic-pare-gt8 (nostalgic-pare-gt8): Get https://nostalgic-pare-gt8:10250/stats/summary/: dial tcp: lookup nostalgic-pare-gt8 on 10.245.0.10:53: no such host` – FakeAccount Oct 18 '18 at 12:13
  • @FakeAccount Use this argument for metrics-server: --kubelet-preferred-address-types=InternalIP,Hostname,InternalDNS,ExternalIP,ExternalDNS – dataviruset May 05 '19 at 12:13
  • 1
    I have kube-state-metrics still I get admin@ip-172-21-59-122:~$ kubectl top nodes Error from server (NotFound): the server could not find the requested resource (get services http:heapster:) admin@ip-172-21-59-122:~$ kubectl top nodes -n kube-system Error from server (NotFound): the server could not find the requested resource (get services http:heapster:) – Ashish Karpe Apr 29 '20 at 07:59