<p>I am using Kube version v1.13.0. Since Heapster is depreciated from v1.11 I am stuck in enabling the API server for cluster Metrics to implement HPA.</p>
<pre><code>root:~# kubectl get pods,deployment,hpa
NAME                                   READY   STATUS    RESTARTS   AGE
pod/ctauthorization-754c686bc6-6adkx   1/1     Running   0          72s
pod/ctauthorization-754c686bc6-dpsbm   1/1     Running   0          57s
pod/ctauthorization-754c686bc6-qsavs   1/1     Running   0          72s

NAME                                    READY   UP-TO-DATE   AVAILABLE   AGE
deployment.extensions/ctauthorization   3/3     3            3           72s

NAME                                                  REFERENCE                    TARGETS                           MINPODS   MAXEODS   REPLICAS   AGE
horizontalpodautoscaler.autoscaling/ctauthorization   Deployment/ctauthorization   &lt;unknown&gt;/1000Mi, &lt;unknown&gt;/50%   3         5         3          72s

</code></pre>
<p>Can someone guide me for step by step enable for the API Metrics server or any Demo video. It would be really helpful to proceed further.</p>
<p>Please let me know if any further information needed.</p>
<p>Thanks
Deena</p>

DeenaDeepak
<p>I am able to implement HPA using <code>metrics-server</code> as heapster is depreciated. I have followed the following steps:</p>

<ol>
<li>Clone the metrics-server github repo: <code>git clone https://github.com/kubernetes-incubator/metrics-server.git</code></li>
</ol>

<p>Go into directory <code>cd deploy/1.8+</code> and run following yaml files:</p>

<pre><code>[root@ip-10-0-1-91 1.8+]# kubectl apply -f aggregated-metrics-reader.yaml 
clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created
[root@ip-10-0-1-91 1.8+]# kubectl apply -f auth-reader.yaml 
rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created
[root@ip-10-0-1-91 1.8+]# kubectl apply -f auth-delegator.yaml 
clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created
[root@ip-10-0-1-91 1.8+]# kubectl apply -f metrics-apiservice.yaml 
apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created
[root@ip-10-0-1-91 1.8+]# kubectl apply -f resource-reader.yaml 
clusterrole.rbac.authorization.k8s.io/system:metrics-server created
clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created
[root@ip-10-0-1-91 1.8+]# kubectl apply -f metrics-server-deployment.yaml 
serviceaccount/metrics-server created
deployment.extensions/metrics-server created
[root@ip-10-0-1-91 1.8+]# kubectl apply -f metrics-server-service.yaml 
service/metrics-server created
</code></pre>

<p>Now create a pod you want to test for autoscaling (taken from kubernetes official docs):</p>

<pre><code>[root@ip-10-0-1-91 auto]#  kubectl run --generator=run-pod/v1 php-apache -- 
image=k8s.gcr.io/hpa-example --requests=cpu=200m --expose --port=80
service/php-apache created
deployment.apps/php-apache created
</code></pre>

<p>Now create a autoscale deployment:</p>

<pre><code>[root@ip-10-0-1-91 auto]# kubectl autoscale deployment php-apache --cpu-percent=50 --min=1 --max=10
horizontalpodautoscaler.autoscaling/php-apache autoscaled
</code></pre>

<p>Now check the HPA, your metrics are coming or not:</p>

<pre><code>[root@ip-10-0-1-91 manifests]# kubectl get hpa
NAME         REFERENCE               TARGETS   MINPODS   MAXPODS   REPLICAS   AGE
php-apache   Deployment/php-apache   0%/50%    1         10        1          2m
</code></pre>

<p>Now generate load from another window using:</p>

<pre><code>kubectl run -i --tty load-generator --image=busybox /bin/sh
</code></pre>

<p>It will open a sh terminal and you can run a load from that sh terminal using:</p>

<pre><code>while true; do wget -q -O- http://php-apache.default.svc.cluster.local; done
</code></pre>

<p>It will take a minute or so to take enough load on your pod and you see a boom:</p>

<pre><code>[root@ip-10-0-1-91 manifests]# kubectl get hpa
NAME         REFERENCE               TARGETS    MINPODS   MAXPODS   REPLICAS   AGE
php-apache   Deployment/php-apache   120%/50%   1         10        4          7m
</code></pre>

<p>And pods scaling :</p>

<p><a href="https://i.stack.imgur.com/uPffU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uPffU.png" alt="enter image description here"></a></p>

<p>Hope this helps to get your HPA working.</p>

<p>EDIT:</p>

<p>Replace the <code>metrics-server-deployment.yaml</code> file in <code>deploy/1.8+</code> with the following yaml file:</p>

<pre><code> apiVersion: v1
 kind: ServiceAccount
 metadata:
   name: metrics-server
   namespace: kube-system
 ---
 apiVersion: extensions/v1beta1
 kind: Deployment
 metadata:
   name: metrics-server
   namespace: kube-system
   labels:
     k8s-app: metrics-server
 spec:
   selector:
     matchLabels:
       k8s-app: metrics-server
   template:
     metadata:
       name: metrics-server
       labels:
         k8s-app: metrics-server
     spec:
       serviceAccountName: metrics-server
       volumes:
       # mount in tmp so we can safely use from-scratch images and/or read-only containers
       - name: tmp-dir
         emptyDir: {}
       containers:
       - command:
         - /metrics-server
         - --metric-resolution=30s
         - --kubelet-insecure-tls
         - --kubelet-preferred-address-types=InternalIP
         name: metrics-server
         image: k8s.gcr.io/metrics-server-amd64:v0.3.1
         imagePullPolicy: Always
         volumeMounts:
         - name: tmp-dir
           mountPath: /tmp
</code></pre>

<p>Also, enable the <code>--authentication-token-webhook</code> in kubelet.conf, then you will be able to get the HPA.</p>

<p>EDIT2: You need to set following properties in the deployment file (in your case it is tomcat) for which you are creating HPA, then only your HPA can fetch metrics from your deployment.</p>

<pre><code>resources:
  requests:
    memory: "64Mi"
    cpu: "250m"
  limits:
    memory: "128Mi"
    cpu: "500m"
</code></pre>
