title: kubectl get hpa shows TARGET unknown
body: <p>Why I am getting unknown Target value in kubectl get hpa ? I have installed metrics-server pod which is running fine. But still hpa is not able to get stats of CPU and memory, hence it is not scaling automatically. I know several queries has been asked with same issue earlier in this forum, but each case has different root cause. I am using k8s version v1.18.0 on Ubuntu. Any idea why is behaving like this in my case?</p>
  <pre><code>/home/ster&gt;kubectl get hpa -A
  NAMESPACE   NAME                           REFERENCE                                 TARGETS        MINPODS   MAXPODS   REPLICAS   AGE
  ricplt      deployment-ricplt-e2term-stl1   Deployment/deployment-ricplt-e2term-stl1   &lt;unknown&gt;/3%   1         10        1          102m
  /home/ster&gt;
  
  /home/ster&gt;kubectl get pods -A | grep metrics-server
  kube-system            metrics-server-585bd46ccb-55q59                            1/1     Running             0          6s
  /home/ster&gt;
  </code></pre>
  <p>metrics-server log</p>
  <pre><code>/home/ster&gt;kubectl logs metrics-server-585bd46ccb-55q59 -n kube-system
  I0427 15:24:41.386570       1 serving.go:342] Generated self-signed cert (/tmp/apiserver.crt, /tmp/apiserver.key)
  I0427 15:24:41.933875       1 requestheader_controller.go:169] Starting RequestHeaderAuthRequestController
  I0427 15:24:41.933903       1 shared_informer.go:240] Waiting for caches to sync for RequestHeaderAuthRequestController
  I0427 15:24:41.933947       1 configmap_cafile_content.go:201] &quot;Starting controller&quot; name=&quot;client-ca::kube-system::extension-apiserver-authentication::client-ca-file&quot;
  I0427 15:24:41.933976       1 shared_informer.go:240] Waiting for caches to sync for client-ca::kube-system::extension-apiserver-authentication::client-ca-file
  I0427 15:24:41.934071       1 configmap_cafile_content.go:201] &quot;Starting controller&quot; name=&quot;client-ca::kube-system::extension-apiserver-authentication::requestheader-client-ca-file&quot;
  I0427 15:24:41.934081       1 shared_informer.go:240] Waiting for caches to sync for client-ca::kube-system::extension-apiserver-authentication::requestheader-client-ca-file
  I0427 15:24:41.934264       1 secure_serving.go:266] Serving securely on [::]:4443
  I0427 15:24:41.934292       1 dynamic_serving_content.go:131] &quot;Starting controller&quot; name=&quot;serving-cert::/tmp/apiserver.crt::/tmp/apiserver.key&quot;
  I0427 15:24:41.934315       1 tlsconfig.go:240] &quot;Starting DynamicServingCertificateController&quot;
  W0427 15:24:41.934691       1 shared_informer.go:372] The sharedIndexInformer has started, run more than once is not allowed
  I0427 15:24:42.033973       1 shared_informer.go:247] Caches are synced for RequestHeaderAuthRequestController
  I0427 15:24:42.034004       1 shared_informer.go:247] Caches are synced for client-ca::kube-system::extension-apiserver-authentication::client-ca-file
  I0427 15:24:42.034105       1 shared_informer.go:247] Caches are synced for client-ca::kube-system::extension-apiserver-authentication::requestheader-client-ca-file
  /home/ster&gt;
  </code></pre>
  <p>metrics-server yaml file</p>
  <pre><code>apiVersion: v1
  kind: ServiceAccount
  metadata:
    labels:
      k8s-app: metrics-server
    name: metrics-server
    namespace: kube-system
  ---
  apiVersion: rbac.authorization.k8s.io/v1
  kind: ClusterRole
  metadata:
    labels:
      k8s-app: metrics-server
      rbac.authorization.k8s.io/aggregate-to-admin: &quot;true&quot;
      rbac.authorization.k8s.io/aggregate-to-edit: &quot;true&quot;
      rbac.authorization.k8s.io/aggregate-to-view: &quot;true&quot;
    name: system:aggregated-metrics-reader
  rules:
  - apiGroups:
    - metrics.k8s.io
    resources:
    - pods
    - nodes
    verbs:
    - get
    - list
    - watch
  ---
  apiVersion: rbac.authorization.k8s.io/v1
  kind: ClusterRole
  metadata:
    labels:
      k8s-app: metrics-server
    name: system:metrics-server
  rules:
  - apiGroups:
    - &quot;&quot;
    resources:
    - nodes/metrics
    verbs:
    - get
  - apiGroups:
    - &quot;&quot;
    resources:
    - pods
    - nodes
    verbs:
    - get
    - list
    - watch
  ---
  apiVersion: rbac.authorization.k8s.io/v1
  kind: RoleBinding
  metadata:
    labels:
      k8s-app: metrics-server
    name: metrics-server-auth-reader
    namespace: kube-system
  roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: Role
    name: extension-apiserver-authentication-reader
  subjects:
  - kind: ServiceAccount
    name: metrics-server
    namespace: kube-system
  ---
  apiVersion: rbac.authorization.k8s.io/v1
  kind: ClusterRoleBinding
  metadata:
    labels:
      k8s-app: metrics-server
    name: metrics-server:system:auth-delegator
  roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: ClusterRole
    name: system:auth-delegator
  subjects:
  - kind: ServiceAccount
    name: metrics-server
    namespace: kube-system
  ---
  apiVersion: rbac.authorization.k8s.io/v1
  kind: ClusterRoleBinding
  metadata:
    labels:
      k8s-app: metrics-server
    name: system:metrics-server
  roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: ClusterRole
    name: system:metrics-server
  subjects:
  - kind: ServiceAccount
    name: metrics-server
    namespace: kube-system
  ---
  apiVersion: v1
  kind: Service
  metadata:
    labels:
      k8s-app: metrics-server
    name: metrics-server
    namespace: kube-system
  spec:
    ports:
    - name: https
      port: 443
      protocol: TCP
      targetPort: https
    selector:
      k8s-app: metrics-server
  ---
  apiVersion: apps/v1
  kind: Deployment
  metadata:
    labels:
      k8s-app: metrics-server
    name: metrics-server
    namespace: kube-system
  spec:
    selector:
      matchLabels:
        k8s-app: metrics-server
    strategy:
      rollingUpdate:
        maxUnavailable: 0
    template:
      metadata:
        labels:
          k8s-app: metrics-server
      spec:
        containers:
        - args:
          - --cert-dir=/tmp
          - --secure-port=4443
          - --kubelet-preferred-address-types=InternalIP
          - --kubelet-use-node-status-port
          - --metric-resolution=30s
          image: k8s.gcr.io/metrics-server/metrics-server:v0.6.1
          imagePullPolicy: IfNotPresent
          #livenessProbe:
           # failureThreshold: 3
           # httpGet:
           #   path: /livez
           #   port: https
           #   scheme: HTTPS
           # periodSeconds: 10
          name: metrics-server
          ports:
          - containerPort: 4443
            name: https
            protocol: TCP
          #readinessProbe:
          #  failureThreshold: 3
          #  httpGet:
          #    path: /readyz
          #    port: https
          #    scheme: HTTPS
          #  initialDelaySeconds: 20
          #  periodSeconds: 10
          resources:
            requests:
              cpu: 100m
              memory: 200Mi
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            runAsNonRoot: true
            runAsUser: 1000
          volumeMounts:
          - mountPath: /tmp
            name: tmp-dir
        nodeSelector:
          kubernetes.io/os: linux
        priorityClassName: system-cluster-critical
        serviceAccountName: metrics-server
        volumes:
        - emptyDir: {}
          name: tmp-dir
  ---
  apiVersion: apiregistration.k8s.io/v1
  kind: APIService
  metadata:
    labels:
      k8s-app: metrics-server
    name: v1beta1.metrics.k8s.io
  spec:
    group: metrics.k8s.io
    groupPriorityMinimum: 100
    insecureSkipTLSVerify: true
    service:
      name: metrics-server
      namespace: kube-system
    version: v1beta1
    versionPriority: 100
  </code></pre>
  <p>hpa yaml file</p>
  <pre><code>apiVersion: autoscaling/v2beta2
  kind: HorizontalPodAutoscaler
  metadata:
    name: deployment-ricplt-e2term-stl1
    namespace: ricplt
  spec:
    maxReplicas: 6
    metrics:
      - resource:
          name: memory
          target:
            averageUtilization: 1
            type: Utilization
        type: Resource
      - resource:
          name: cpu
          target:
            averageUtilization: 1
            type: Utilization
        type: Resource
    minReplicas: 1
    scaleTargetRef:
      apiVersion: apps/v1
      kind: Deployment
      name: deployment-ricplt-e2term-stl
  </code></pre>