<p>When I do <code>kubectl top pods/nodes</code> I am getting the following error:</p>
<blockquote>
<p>metrics not available yet</p>
</blockquote>
<p>When I check the logs I am getting</p>
<pre><code>$ kubectl logs metrics-server-7df4c4484d-h75wr -n kube-system -c metrics-server

I1008 12:02:55.159069       1 serving.go:273] Generated self-signed cert(apiserver.local.config/certificates/apiserver.crt, apiserver.local.config/certificates/apiserver.key)
[restful] 2018/10/08 12:02:56 log.go:33: [restful/swagger] listing is available at https://:443/swaggerapi
[restful] 2018/10/08 12:02:56 log.go:33: [restful/swagger] https://:443/swaggerui/ is mapped to folder /swagger-ui/
I1008 12:02:56.358063       1 serve.go:96] Serving securely on [::]:443
E1008 12:03:04.225519       1 reststorage.go:101] unable to fetch node metrics for node &quot;hpa-test&quot;: no metrics known for node &quot;hpa-test&quot;
E1008 12:03:07.619489       1 reststorage.go:101] unable to fetch node metrics for node &quot;hpa-test&quot;: no metrics known for node &quot;hpa-test&quot;
</code></pre>
<p>Also, I am able to ping to hpa-test node from:</p>
<pre><code>$ kubectl exec -it  metrics-server-7df4c4484d-h75wr -n kube-system sh
</code></pre>
<p>Also, I have tried looking for solution everywhere but nothing fixed the issue</p>

<p>There are two ways to fix this problem:</p>

<p>1) using <strong>heapster</strong> :
installing heapster will allow <em>'kubectl top nodes'</em> to work out of the box. However heapster has been deprecated, so you probably should switch to metrics-server.</p>

<p>2) using <strong>metrics-server</strong> :
unfortunately it may not work out of the box when installing metrics-server...
in case it doesn't, you need to update the end of the metrics-server-deployment.yaml (1.8+) file you used for installation and <strong>add a command section</strong> with the right parameters as follow:</p>

<pre><code>containers:
- name: metrics-server
  image: k8s.gcr.io/metrics-server-amd64:v0.3.1
  imagePullPolicy: Always
  volumeMounts:
  - name: tmp-dir
    mountPath: /tmp

  command:
      - /metrics-server
      - --kubelet-insecure-tls
      - --kubelet-preferred-address-types=InternalIP
</code></pre>

<p>then simply apply the changes:</p>

<blockquote>
  <p>kubectl apply -f metrics-server-deployment.yaml</p>
</blockquote>

<p>you should then be able to get results with</p>

<blockquote>
  <p>kubectl top nodes</p>
</blockquote>

<p>and</p>

<blockquote>
  <p>kubectl get --raw "/apis/metrics.k8s.io/v1beta1/nodes"</p>
</blockquote>
