title: Kubernetes AutoScaler Not Scaling, HPA shows target <unknown>
body: <p>I'm pretty new to kubernetes, not so much with docker.</p>
  
  <p>I've been working through the example but I am stuck with the autoscaler, (which doesn't seem to scale).</p>
  
  <p>I am working through the example here <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#step-one-run--expose-php-apache-server" rel="noreferrer">https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#step-one-run--expose-php-apache-server</a></p>
  
  <p>You'll find the build at the bottom</p>
  
  <p><code>kubectl create -f https://k8s.io/docs/tasks/run-application/hpa-php-apache.yaml</code></p>
  
  <p>Which looks like this </p>
  
  <pre><code>apiVersion: autoscaling/v1
  kind: HorizontalPodAutoscaler
  metadata:
    name: php-apache
    namespace: default
  spec:
    scaleTargetRef:
      apiVersion: apps/v1
      kind: Deployment
      name: php-apache
    minReplicas: 1
    maxReplicas: 10
    targetCPUUtilizationPercentage: 50
  </code></pre>
  
  <p><code>kubectl get hba</code> shows</p>
  
  <pre><code>NAME         REFERENCE               TARGETS         MINPODS   MAXPODS   REPLICAS   AGE
  php-apache   Deployment/php-apache   &lt;unknown&gt;/50%   1         10        0          7s
  </code></pre>
  
  <p>Clue in the <code>&lt;unknown&gt;</code> section.</p>
  
  <p>Then <code>kubectl describe hba</code> shows</p>
  
  <pre><code>Name:                                                  php-apache
  Namespace:                                             default
  Labels:                                                &lt;none&gt;
  Annotations:                                           &lt;none&gt;
  CreationTimestamp:                                     Sat, 14 Apr 2018 23:05:05 +0100
  Reference:                                             Deployment/php-apache
  Metrics:                                               ( current / target )
    resource cpu on pods  (as a percentage of request):  &lt;unknown&gt; / 50%
  Min replicas:                                          1
  Max replicas:                                          10
  Conditions:
    Type         Status  Reason          Message
    ----         ------  ------          -------
    AbleToScale  False   FailedGetScale  the HPA controller was unable to get the target's current scale: deployments/scale.extensions "php-apache" not found
  Events:
    Type     Reason          Age                From                       Message
    ----     ------          ----               ----                       -------
    Warning  FailedGetScale  12s (x14 over 6m)  horizontal-pod-autoscaler  deployments/scale.extensions "php-apache" not found
  </code></pre>
  
  <p>So then I manually add it in with...</p>
  
  <p><code>kubectl run php-apache --image=k8s.gcr.io/hpa-example --requests=cpu=200m --expose --port=80</code></p>
  
  <p>Then if i run <code>kubectl describe hpa</code> again I get this error..</p>
  
  <pre><code>Name:                                                  php-apache
  Namespace:                                             default
  Labels:                                                &lt;none&gt;
  Annotations:                                           &lt;none&gt;
  CreationTimestamp:                                     Sat, 14 Apr 2018 23:05:05 +0100
  Reference:                                             Deployment/php-apache
  Metrics:                                               ( current / target )
    resource cpu on pods  (as a percentage of request):  &lt;unknown&gt; / 50%
  Min replicas:                                          1
  Max replicas:                                          10
  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: unable to get metrics for resource cpu: unable to fetch metrics from API: the server could not find the requested resource (get pods.metrics.k8s.io)
  Events:
    Type     Reason                        Age                From                       Message
    ----     ------                        ----               ----                       -------
    Warning  FailedGetScale                1m (x21 over 11m)  horizontal-pod-autoscaler  deployments/scale.extensions "php-apache" not found
    Warning  FailedGetResourceMetric       8s (x2 over 38s)   horizontal-pod-autoscaler  unable to get metrics for resource cpu: unable to fetch metrics from API: the server could not find the requested resource (get pods.metrics.k8s.io)
    Warning  FailedComputeMetricsReplicas  8s (x2 over 38s)   horizontal-pod-autoscaler  failed to get cpu utilization: unable to get metrics for resource cpu: unable to fetch metrics from API: the server could not find the requested resource (get pods.metrics.k8s.io)
  </code></pre>