<p>I'v enabled heapster on minikube</p>

<pre><code>minikube addons start heapster
</code></pre>

<p>And custom metrics with</p>

<pre><code>minikube start --extra-config kubelet.EnableCustomMetrics=true
</code></pre>

<p>My deployment looks like</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: kubia
spec:
  replicas: 1
  template:
    metadata:
      name: kubia
      labels:
        app: kubia
      annotations:
        pod.beta.kubernetes.io/init-containers: '[
            {
                "name": "setup",
                "image": "busybox",
                "imagePullPolicy": "IfNotPresent",
                "command": ["sh", "-c", "echo \"{\\\"endpoint\\\": \\\"http://$POD_IP:8080/metrics\\\"}\" &gt; /etc/custom-metrics/definition.json"],
                "env": [{
                  "name": "POD_IP",
                  "valueFrom": {
                    "fieldRef": {
                      "apiVersion": "v1",
                      "fieldPath": "status.podIP"
                    }
                  }
                }],
                "volumeMounts": [
                    {
                        "name": "config",
                        "mountPath": "/etc/custom-metrics"
                    }
                ]
            }
        ]'
    spec:
      containers:
      - image: luksa/kubia:qps
        name: nodejs
        ports:
          - containerPort: 8080
        volumeMounts:
        - name: config
          mountPath: /etc/custom-metrics
        resources:
          requests:
            cpu: 100m
      volumes:
      - name: config
        emptyDir:
</code></pre>

<p>My hpa looks like</p>

<pre><code>apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: kubia
  annotations:
    alpha/target.custom-metrics.podautoscaler.kubernetes.io: '{"items":[{"name":"qps", "value": "20"}]}'
spec:
  maxReplicas: 5
  minReplicas: 1
  scaleTargetRef:
    apiVersion: extensions/v1beta1
    kind: Deployment
    name: kubia
  targetCPUUtilizationPercentage: 1000000
</code></pre>

<p>However I get target unknown</p>

<pre><code>jonathan@ubuntu ~&gt; kubectl get hpa
NAME      REFERENCE          TARGETS                MINPODS   MAXPODS   REPLICAS   AGE
kubia     Deployment/kubia   &lt;unknown&gt; / 1000000%   1         5         1          31m
</code></pre>

<p>And the following warnings from the hpa</p>

<pre><code>  Warning  FailedGetResourceMetric       27m (x12 over 33m)  horizontal-pod-autoscaler  unable to get metrics for resource cpu: no metrics returned from heapster
  Warning  FailedComputeMetricsReplicas  27m (x12 over 33m)  horizontal-pod-autoscaler  failed to get cpu utilization: unable to get metrics for resource cpu: no metrics returned from heapster
</code></pre>

<blockquote>
  <p><code>metrics-server</code> monitoring needs to be deployed in the cluster to
  provide metrics via the resource metrics API, as Horizontal Pod
  Autoscaler uses this API to collect metrics.</p>
</blockquote>

<p>Thus enable <code>metrics-server</code> addon via;</p>

<pre><code>$ minikube addons enable metrics-server
</code></pre>

<p>Refer - <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#before-you-begin" rel="nofollow noreferrer">Horizontal Pod Autoscaler Walkthrough - Before you begin</a></p>
