title: Kubernetes metrics-server doesn't provide all metrics or scale HPA
body: <p>Following the example here <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects</a>, I have created installed metrics-server and modified it as follows:</p>
  <pre><code>    spec:
        containers:
        - command:
          - metrics-server
          - --secure-port=8443
          - --kubelet-insecure-tls=true
          - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
          image: docker.io/bitnami/metrics-server:0.3.7-debian-10-r89
          imagePullPolicy: IfNotPresent
          name: metrics-server
          ports:
          - containerPort: 8443
            name: https
            protocol: TCP
          resources: {}
  </code></pre>
  <p>My nodes are listed when queried:</p>
  <pre><code>kubectl get --raw &quot;/apis/metrics.k8s.io/v1beta1/nodes&quot;
  {&quot;kind&quot;:&quot;NodeMetricsList&quot;,&quot;apiVersion&quot;:&quot;metrics.k8s.io/v1beta1&quot;,&quot;metadata&quot;:{&quot;selfLink&quot;:&quot;/apis/metrics.k8s.io/v1beta1/nodes&quot;},&quot;items&quot;:[{&quot;metadata&quot;:{&quot;name&quot;:&quot;eo-test-metrics-35lks&quot;,&quot;selfLink&quot;:&quot;/apis/metrics.k8s.io/v1beta1/nodes/eo-test-metrics-35lks&quot;,&quot;creationTimestamp&quot;:&quot;2020-11-04T04:05:58Z&quot;},&quot;timestamp&quot;:&quot;2020-11-04T04:05:28Z&quot;,&quot;window&quot;:&quot;30s&quot;,&quot;usage&quot;:{&quot;cpu&quot;:&quot;770120208n&quot;,&quot;memory&quot;:&quot;934476Ki&quot;}},{&quot;metadata&quot;:{&quot;name&quot;:&quot;eo-test-metrics-35lkp&quot;,&quot;selfLink&quot;:&quot;/apis/metrics.k8s.io/v1beta1/nodes/eo-test-metrics-35lkp&quot;,&quot;creationTimestamp&quot;:&quot;2020-11-04T04:05:58Z&quot;},&quot;timestamp&quot;:&quot;2020-11-04T04:05:25Z&quot;,&quot;window&quot;:&quot;30s&quot;,&quot;usage&quot;:{&quot;cpu&quot;:&quot;483763591n&quot;,&quot;memory&quot;:&quot;850756Ki&quot;}}]}
  </code></pre>
  <p>But, the HPA targets remain 'unknown':</p>
  <pre><code>kubectl get hpa
  NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
  php-apache Deployment/php-apache &lt;unknown&gt;/50% 1 10 1 31m
  </code></pre>
  <p>Running top nodes works but top pods does not</p>
  <pre><code>kubectl top nodes
  NAME                    CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%
  eo-test-metrics-35lkp   93m          4%     934Mi           30%
  eo-test-metrics-35lks   166m         8%     1053Mi          33%
  </code></pre>
  <p>Top pods return error <code>error: Metrics not available</code>:</p>
  <pre><code> kubectl top pods
  W1104 11:19:27.854485   62798 top_pod.go:266] Metrics not available for pod default/php-apache-d4cf67d68-blt2c, age: 13h1m51.854463s
  error: Metrics not available for pod default/php-apache-d4cf67d68-blt2c, age: 13h1m51.854463s
  </code></pre>
  <p>This is on Kubernetes server version <code>v1.19.3</code> and metrics server version <code>0.3.6</code></p>
  <p>The logs from metrics-server</p>
  <pre><code>E1104 21:21:56.496129       1 reststorage.go:160] unable to fetch pod metrics for pod default/php-apache-d4cf67d68-blt2c: no metrics known for pod
  E1104 21:22:10.945091       1 reststorage.go:160] unable to fetch pod metrics for pod default/php-apache-d4cf67d68-blt2c: no metrics known for pod
  E1104 21:22:26.496814       1 reststorage.go:160] unable to fetch pod metrics for pod default/php-apache-d4cf67d68-blt2c: no metrics known for pod
  </code></pre>