<p>Attempting to deploy autoscaling to my cluster, but the target shows &quot;unknown&quot;, I have tried different metrics servers to no avail. I followed [this githhub issue](https&quot;//github.com/kubernetes/minikube/issues4456/) even thought I'm using Kubeadm not minikube and it did not change the problem.</p>
<p>I also <a href="https://stackoverflow.com/questions/54106725/docker-kubernetes-mac-autoscaler-unable-to-find-metrics">followed this Stack post</a> with no success either.</p>
<p>I'm running Ubuntu 20.0.4 LTS.</p>
<p>Using kubernetes version 1.23.5, for kubeadm ,kubcectl, ect</p>
<p>Following the advice the other stack post, I grabbed the latest version via curl</p>
<p><code>curl -L https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml</code></p>
<p>I edited the file to be as followed:</p>
<pre><code>    spec:
      containers:
      - args:
        - --cert-dir=/tmp
        - --secure-port=4443
        - --kubectl-insecure-tls
        - --kubelet-preferred-address-types=InternalIP
        - --kubelet-use-node-status-port
        - --metric-resolution=15s
        image: k8s.gcr.io/metrics-server/metrics-server:v0.6.1
        imagePullPolicy: IfNotPresent
</code></pre>
<p>I then ran kubectl apply -f components.yaml</p>
<p>Still did not work:</p>
<p>$ kubectl get hpa
NAME                 REFERENCE                   TARGETS         MINPODS   MAXPODS   REPLICAS   AGE
teastore-webui-hpa   Deployment/teastore-webui   &lt;unknown&gt;/50%   1         20        1          20h</p>
<p>Another suggestion was specifically declaring limits.</p>
<pre><code>$ kubectl autoscale deployment teastore-webui --max=20 --cpu-percent=50 --min=1
horizontalpodautoscaler.autoscaling/teastore-webui autoscaled
 
group8@group8:~/Downloads/TeaStore-master/examples/kubernetes$ kubectl get hpa
NAME                 REFERENCE                   TARGETS         MINPODS   MAXPODS   REPLICAS   AGE
teastore-webui       Deployment/teastore-webui   &lt;unknown&gt;/50%   1         20        0          4s
teastore-webui-hpa   Deployment/teastore-webui   &lt;unknown&gt;/50%   1         20        1          20h
</code></pre>
<p>That also did not work.</p>
<p>Here is an exert of the deployment and service config that I'm trying to autoscale.</p>
<pre><code>    spec:
      containers:
        - name: teastore-webui
          image: descartesresearch/teastore-webui
          ports:
            - containerPort: 8080
          env:
            - name: HOST_NAME
              value: &quot;teastore-webui&quot;
            - name: REGISTRY_HOST
              value: &quot;teastore-registry&quot;
          resources:
            requests:
              cpu: &quot;250m&quot;
---
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: teastore-webui-hpa
  labels:
    app: teastore
spec:
  maxReplicas: 20
  minReplicas: 1
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: teastore-webui
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 50
---
apiVersion: v1
kind: Service
metadata:
  name: teastore-webui
  labels:
    app: teastore
    run: teastore-webui
spec:
  type: NodePort
  ports:
    - port: 8080
      nodePort: 30080
      protocol: TCP
  selector:
    run: teastore-webui
</code></pre>
<p>Based on other suggestions I have the resource specifically declared as cpu with 50% utilization, and CPU requests are set to 250 milicores.</p>
<pre><code>   $kubectl describe hpa
Warning: autoscaling/v2beta2 HorizontalPodAutoscaler is deprecated in v1.23+, unavailable in v1.26+; use autoscaling/v2 HorizontalPodAutoscaler
Name:                                                  teastore-webui
Namespace:                                             default
Labels:                                                &lt;none&gt;
Annotations:                                           &lt;none&gt;
CreationTimestamp:                                     Sat, 02 Apr 2022 16:07:25 -0400
Reference:                                             Deployment/teastore-webui
Metrics:                                               ( current / target )
  resource cpu on pods  (as a percentage of request):  &lt;unknown&gt; / 50%
Min replicas:                                          1
Max replicas:                                          20
Deployment pods:                                       1 current / 0 desired
Conditions:
  Type           Status  Reason                   Message
  ----           ------  ------                   -------
  AbleToScale    True    SucceededGetScale        the HPA controller was able to get the target's current scale
  ScalingActive  False   FailedGetResourceMetric  the HPA was unable to compute the replica count: failed to get cpu utilization: unable to get metrics for resource cpu: unable to fetch metrics from resource metrics API: the server is currently unable to handle the request (get pods.metrics.k8s.io)
Events:
  Type     Reason                        Age                    From                       Message
  ----     ------                        ----                   ----                       -------
  Warning  FailedComputeMetricsReplicas  29m (x12 over 32m)     horizontal-pod-autoscaler  invalid metrics (1 invalid out of 1), first error is: failed to get cpu utilization: unable to get metrics for resource cpu: unable to fetch metrics from resource metrics API: the server is currently unable to handle the request (get pods.metrics.k8s.io)
  Warning  FailedGetResourceMetric       2m12s (x121 over 32m)  horizontal-pod-autoscaler  failed to get cpu utilization: unable to get metrics for resource cpu: unable to fetch metrics from resource metrics API: the server is currently unable to handle the request (get pods.metrics.k8s.io)
</code></pre>

<p>Syntaxerror on line 6 of this yaml. It needs to be <code>- --kubelet-insecure-tls</code> and not <code>- --kubectl-insecure-tls</code></p>
<pre><code>spec:
  containers:
  - args:
    - --cert-dir=/tmp
    - --secure-port=4443
    - --kubectl-insecure-tls
    - --kubelet-preferred-address-types=InternalIP
    - --kubelet-use-node-status-port
    - --metric-resolution=15s
    image: k8s.gcr.io/metrics-server/metrics-server:v0.6.1
    imagePullPolicy: IfNotPresent
</code></pre>
<p>Noticed by checking the log files with</p>
<pre><code>kubectl logs -f metric-server -n kube-system
</code></pre>
<p>Thank you David Maze for the comment.</p>
