<p><strong>UPDATE:</strong> I'm deploying on AWS cloud with the help of kops.</p>

<p>I'm in the process applying HPA for one of my kubernete deployment.
While testing the sample app, I deployed with default namespace, I can see the metrics being exposed as below ( showing current utilisation is 0%)</p>

<pre><code>$ kubectl  run busybox --image=busybox --port 8080           -- sh -c "while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; \
         env | grep HOSTNAME | sed 's/.*=//g'; } | nc -l -p  8080; done"


$ kubectl get hpa
NAME          REFERENCE                TARGETS   MINPODS   MAXPODS   REPLICAS   AGE
busybox       Deployment/busybox       0%/20%    1         4         1          14m
</code></pre>

<p>But when I deploy with the custom namespace ( example: test), the current utilisation is showing unknown </p>

<pre><code> $ kubectl get hpa --namespace test
NAME        REFERENCE            TARGETS                          MINPODS   MAXPODS   REPLICAS   AGE
busybox     Deployment/busybox   &lt;unknown&gt;/20%                    1         4         1          25m
</code></pre>

<p>Can someone please suggest whats wrong here?</p>

<p>For future you need to meet few conditions for HPA to work. You need to have metrics server or heapster running on your cluster. What is important is to set resources on namespace basis.</p>

<p>You did not provide in what environment is your cluster running, but in GKE by default you have a cpu resource set (100m), but you need to specify it on new namespaces:</p>

<blockquote>
  <p>Please note that if some of the pod’s containers do not have the
  relevant resource request set, CPU utilization for the pod will not be
  defined and the autoscaler will not take any action for that metric.</p>
</blockquote>

<p>In your case I am not sure why it does work after redeploy, as there is not enough information. But for future remember to:</p>

<p>1) object that you want to scale and HPA should be in the same namespace</p>

<p>2) set  resources on CPU per namespace or simply add <code>--requests=cpu=value</code> so the HPA will be able to scale based on that. </p>

<p><strong>UPDATE</strong>:</p>

<p>for your particular case:</p>

<p>1) <code>kubectl  run busybox --image=busybox --port 8080 -n test --requests=cpu=200m  -- sh -c "while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; \
env | grep HOSTNAME | sed 's/.*=//g'; } | nc -l -p  8080; done"</code></p>

<p>2) <code>kubectl autoscale deployment busybox --cpu-percent=50 --min=1 --max=10 -n test</code></p>
