<p>I'm using Kubernetes 1.7 and running hepaster. When I run </p>

<pre><code>kubectl top nodes --heapster-namespace=kube-system
</code></pre>

<p>it shows me </p>

<pre><code>error: metrics not available yet
</code></pre>

<p>I also tried this</p>

<pre><code>kubectl top nodes --heapster-namespace=kube-system --heapster-service=heapster --heapster-scheme=http --heapster-port=12213
</code></pre>

<p>Where the heapster is running then it shows following error.</p>

<pre><code>Error from server (ServiceUnavailable): the server is currently unable to handle the request (get services http:heapster:12213)
</code></pre>

<p>Any clue for tackling the error?</p>

<p>It means that heapster is not properly configured.</p>

<p>You need to make sure that heapster is running on <code>kube-system</code> namespace, and check if the <code>/healthz</code> endpoint is ok:</p>

<pre><code>$ export HEAPSTER_POD=$(kubectl get po -l k8s-app=heapster -n kube-system -o jsonpath='{.items[*].metadata.name}')
$ export HEAPSTER_SERVICE=$(kubectl get service/heapster --namespace=kube-system -o jsonpath="{.spec.clusterIP}")
$ curl -L "http://${HEAPSTER_SERVICE}/healthz"
ok
</code></pre>

<p>Then, you can check if the metrics API is available:</p>

<pre><code>$ curl -L "http://${HEAPSTER_SERVICE}/api/v1/model/metrics/"
[
  "cpu/usage_rate",
  "memory/usage",
  "cpu/request",
  "cpu/limit",
  "memory/request",
  "memory/limit"
 ]
</code></pre>

<p>If it's not returning as above, take a look at container logs for errors:</p>

<p><code>$ kubectl logs -n kube-system ${HEAPSTER_POD} --all-containers</code></p>

<hr>

<p>Although, keep in mind that Heapster is a deprecated project and you may have problems when running it in recent Kubernetes versions.</p>

<p>See <a href="https://github.com/kubernetes-retired/heapster/blob/master/docs/deprecation.md" rel="nofollow noreferrer">Heapster Deprecation Timeline</a>:</p>

<blockquote>
<pre><code>| Kubernetes Release  | Action              | Policy/Support                                                                   |
|---------------------|---------------------|----------------------------------------------------------------------------------|
| Kubernetes 1.11     | Initial Deprecation | No new features or sinks are added.  Bugfixes may be made.                       |
| Kubernetes 1.12     | Setup Removal       | The optional to install Heapster via the Kubernetes setup script is removed.     |
| Kubernetes 1.13     | Removal             | No new bugfixes will be made.  Move to kubernetes-retired organization.          |
</code></pre>
</blockquote>

<p>Since Kubernetes v1.10, the <code>kubectl top</code> relies on <strong>metrics-server</strong> by default.</p>

<p><a href="https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.10.md#other-notable-changes-20" rel="nofollow noreferrer">CHANGELOG-1.10.md</a>:</p>

<blockquote>
  <ul>
  <li>Support metrics API in <code>kubectl top</code> commands. (<a href="https://github.com/kubernetes/kubernetes/pull/56206" rel="nofollow noreferrer">#56206</a>, @brancz)</li>
  </ul>
  
  <p>This PR implements support for the <code>kubectl top</code> commands to use the
  metrics-server as an aggregated API, instead of requesting the metrics
  from heapster directly. If the <code>metrics.k8s.io</code> API is not served by the
  apiserver, then this still falls back to the previous behavior.</p>
</blockquote>

<p>It's better to use a <code>kubectl</code> version <code>v1.10</code> or above, as it fetches the metrics from metrics-server.</p>

<p>However, beware of <a href="https://kubernetes.io/docs/setup/version-skew-policy/#kubectl" rel="nofollow noreferrer"><code>kubectl</code> Version Skew Policy</a>:</p>

<blockquote>
  <p><code>kubectl</code> is supported within one minor version (older or newer) of
  <code>kube-apiserver</code></p>
</blockquote>

<p>Check your <code>kube-apiserver</code> version before choosing your <code>kubectl</code> version.</p>
