<p>I am working in set up a kubernetes cluster using the following stuff:</p>

<ul>
<li><strong>AWS</strong> as a cloud provider</li>
<li><strong>kops (Version 1.6.0-alpha, just to test)</strong> as a cli tool to create and manage cluster</li>
<li><strong>kubectl (server : v1.6.2 and client : 1.6.0 )</strong> to control my cluster</li>
<li>Ubuntu 16 as a local OS</li>
</ul>

<p>I have a simple k8s cluster with the following stuff:</p>

<ul>
<li><strong>AWS region</strong> : us-west-2</li>
<li>One <strong>master</strong> over : t2.medium
/ k8s-1.5-debian-jessie-amd64-hvm-ebs-2017-01-09</li>
<li>One <strong>node</strong> onver : t2.medium
/ k8s-1.5-debian-jessie-amd64-hvm-ebs-2017-01-09</li>
</ul>

<p>I also have some pods deployed over the cluster and I created jmeter stress test to generate artificial traffic.</p>

<p>My question is <strong>How can I create a auto-scaling node on a k8s cluster using kops over aws?</strong></p>

<p>I just found the following ad-don <a href="https://github.com/kubernetes/kops/tree/master/addons/cluster-autoscaler" rel="nofollow noreferrer">kops addons</a> in kops repository. I deployed as the docs says and it is available.</p>

<p>My parameters were:</p>

<pre><code>CLOUD_PROVIDER=aws
IMAGE=gcr.io/google_containers/cluster-autoscaler:v0.4.0
MIN_NODES=1
MAX_NODES=3
AWS_REGION=us-east-2
GROUP_NAME="&lt;the-auto-scaling-group-Name&gt;"
SSL_CERT_PATH="/etc/ssl/certs/ca-certificates.crt" # (/etc/ssl/certs for gce)


$ kubectl get deployments --namespace=kube-system

NAME                   DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
cluster-autoscaler     1         1         1            1           3h
dns-controller         1         1         1            1           3h
kube-dns               2         2         2            2           3h
kube-dns-autoscaler    1         1         1            1           3h
kubernetes-dashboard   1         1         1            1           3h
</code></pre>

<p>However, after stress my node using a pod with stress containers nothing happens (100% cpu utilization) and my auto-scaling group is not modified.</p>

<p><a href="https://i.stack.imgur.com/BXbib.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BXbib.png" alt="cpu utilization"></a></p>

<p><a href="https://i.stack.imgur.com/DGS7f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DGS7f.png" alt="auto-scaling group"></a></p>

<p>In the other hand, I export the kops output in terraform but there ia not auto scaling policies to generate auto-scaling base on cpu utilization.</p>

<p>Finally, I could find an <a href="http://blog.kubernetes.io/2016/07/autoscaling-in-kubernetes.html" rel="nofollow noreferrer">entry</a> in the k8s blog which indicates that it will be support in the future by AWS but there is not other announcement about it.  </p>

<p>Any suggestion or experience with that task in AWS and kops?. Next I will try to generate auto-scaling policies manually just to test.</p>

<p>Firstly you <a href="https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler#releases" rel="nofollow noreferrer">should use</a> autoscaler <code>gcr.io/google_containers/cluster-autoscaler:v0.5.0</code> when using Kubernetes <code>1.6.x</code> .</p>

<p>Secondly from my understanding the autoscaler itself only scales the ASG if there is a pod in <code>Pending</code> state because it can't fit in any existing node.</p>

<p>For your use-case, <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/" rel="nofollow noreferrer">Horizontal Pod Autoscaling</a> will scale up your application (which is being stressed) when under high load, make sure to mention the <code>requests</code> portion in the podspec. Once the autoscaler sees newly scaled pods don't fit a node, it will launch new node.</p>

<p>Disclaimer: I haven't played with Horizontal Pod Autoscaling yet.</p>
