<p>I am following this tutorial: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/" rel="noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/</a></p>

<p>I have created the memory pod demo and I am trying to get the metrics from the pod but it is not working.</p>

<p>I installed the metrics server by cloning: <a href="https://github.com/kubernetes-incubator/metrics-server" rel="noreferrer">https://github.com/kubernetes-incubator/metrics-server</a></p>

<p>And then running this command from top level:</p>

<pre><code>kubectl create -f deploy/1.8+/
</code></pre>

<p>I am using kubernetes version 1.10.11.</p>

<p>The pod is definitely created:</p>

<pre><code>λ kubectl get pod memory-demo --namespace=mem-example
NAME          READY     STATUS    RESTARTS   AGE
memory-demo   1/1       Running   0          6m
</code></pre>

<p>But the metics command does not work and gives an error:</p>

<pre><code>λ kubectl top pod memory-demo --namespace=mem-example
Error from server (NotFound): podmetrics.metrics.k8s.io "mem-example/memory-demo" not found
</code></pre>

<p>What did I do wrong?</p>

<p>There are some patches to be done to metrics server deployment to get the metrics working.</p>
<h1>Follow the below steps</h1>
<pre><code>kubectl delete -f deploy/1.8+/

wait till the metrics server gets undeployed

run the below command
kubectl create -f https://raw.githubusercontent.com/epasham/docker-repo/master/k8s/metrics-server.yaml
</code></pre>
<pre><code>master $ kubectl get po -n kube-system
NAME                              READY     STATUS    RESTARTS   AGE
coredns-78fcdf6894-6zg78          1/1       Running   0          2h
coredns-78fcdf6894-gk4sb          1/1       Running   0          2h
etcd-master                       1/1       Running   0          2h
kube-apiserver-master             1/1       Running   0          2h
kube-controller-manager-master    1/1       Running   0          2h
kube-proxy-f5z9p                  1/1       Running   0          2h
kube-proxy-ghbvn                  1/1       Running   0          2h
kube-scheduler-master             1/1       Running   0          2h
metrics-server-85c54d44c8-rmvxh   2/2       Running   0          1m
weave-net-4j7cl                   2/2       Running   1          2h
weave-net-82fzn                   2/2       Running   1          2h
</code></pre>
<pre><code>master $ kubectl top pod -n kube-system
NAME                              CPU(cores)   MEMORY(bytes)
coredns-78fcdf6894-6zg78          2m           11Mi
coredns-78fcdf6894-gk4sb          2m           9Mi
etcd-master                       14m          90Mi
kube-apiserver-master             24m          425Mi
kube-controller-manager-master    26m          62Mi
kube-proxy-f5z9p                  2m           19Mi
kube-proxy-ghbvn                  3m           17Mi
kube-scheduler-master             8m           14Mi
metrics-server-85c54d44c8-rmvxh   1m           19Mi
weave-net-4j7cl                   2m           59Mi
weave-net-82fzn                   1m           60Mi
</code></pre>
<p>Check and verify the below lines in metrics server deployment manifest.</p>
<pre><code>        command:
        - /metrics-server
        - --metric-resolution=30s
        - --kubelet-preferred-address-types=InternalIP
        - --kubelet-insecure-tls
</code></pre>
