<p>How can we get the real resource usage (not resource requests) of each pod on Kubernetes by command line?
Heapster is deprecated.
Meanwhile, Metrics-server still does not support <code>kubectl top pod</code>.</p>

<ol>
<li><p>Heapster - </p>

<p>I deployed Heapster using the following command </p>

<pre><code>$ heapster/deploy/kube.sh start
kubectl get pods --all-namespaces
NAMESPACE     NAME                                                           READY     STATUS    RESTARTS   AGE
kube-system   calico-node-hlcbl                                              2/2       Running   0          39m
kube-system   calico-node-m8jl2                                              2/2       Running   0          35m
kube-system   coredns-78fcdf6894-bl94w                                       1/1       Running   0          39m
kube-system   coredns-78fcdf6894-fwx95                                       1/1       Running   0          39m
kube-system   etcd-ctl.kube.yarnrm-pg0.utah.cloudlab.us                      1/1       Running   0          39m
kube-system   heapster-84c9bc48c4-qzt8x                                      1/1       Running   0          15s
kube-system   kube-apiserver-ctl.kube.yarnrm-pg0.utah.cloudlab.us            1/1       Running   0          39m
kube-system   kube-controller-manager-ctl.kube.yarnrm-pg0.utah.cloudlab.us   1/1       Running   0          38m
kube-system   kube-proxy-nj9f8                                               1/1       Running   0          35m
kube-system   kube-proxy-zvr2b                                               1/1       Running   0          39m
kube-system   kube-scheduler-ctl.kube.yarnrm-pg0.utah.cloudlab.us            1/1       Running   0          39m
kube-system   monitoring-grafana-555545f477-jldmz                            1/1       Running   0          15s
kube-system   monitoring-influxdb-848b9b66f6-k2k4f                           1/1       Running   0          15s
</code></pre>

<p>When I used <code>kubectl top</code>, I encountered the following errors.</p>

<pre><code>$ kubectl top pods
Error from server (ServiceUnavailable): the server is currently unable to handle the request (get services http:heapster:)
$ kubectl top nodes
Error from server (ServiceUnavailable): the server is currently unable to handle the request (get services http:heapster:)
</code></pre></li>
<li><p>metrics-server:</p>

<p>metrics-server has not supported <code>kubectl top</code> <a href="https://github.com/kubernetes/community/blob/master/contributors/design-proposals/instrumentation/resource-metrics-api.md" rel="noreferrer">Resource Metrics API</a></p></li>
</ol>

<p>If anyone already solved the same problem, please help me.
Thanks.</p>

Tan Le
<blockquote>
  <p>Error from server (ServiceUnavailable): the server is currently unable to handle the request (get services http:heapster:)</p>
</blockquote>

<p>It sounds like the heapster deployment just forgot to install the <code>Service</code> for <code>heapster</code>; I would expect this would get you past <em>that</em> error, but unknown whether it would actually cause <code>kubectl top pods</code> to start to work:</p>

<pre><code>kubectl create -f /dev/stdin &lt;&lt;SVC
apiVersion: v1
kind: Service
metadata:
  name: heapster
  namespace: kube-system
spec:
  selector:
    whatever-label: is-on-heapster-pods
  ports:
  - name: http
    port: 80
    targetPort: whatever-is-heapster-is-listening-on
SVC
</code></pre>
