add horizontal DNS autoscaler

Change-Id: I199bf205cb2a3a3436b8e395098f27725dc75d05
diff --git a/kubernetes/files/kube-addons/dns/kubedns-autoscaler.yaml b/kubernetes/files/kube-addons/dns/kubedns-autoscaler.yaml
new file mode 100644
index 0000000..508f19c
--- /dev/null
+++ b/kubernetes/files/kube-addons/dns/kubedns-autoscaler.yaml
@@ -0,0 +1,32 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  name: kube-dns-autoscaler
+  namespace: kube-system
+  labels:
+    k8s-app: kube-dns-autoscaler
+spec:
+  template:
+    metadata:
+      labels:
+        k8s-app: kube-dns-autoscaler
+    spec:
+      containers:
+      - name: autoscaler
+        image: gcr.io/google_containers/cluster-proportional-autoscaler-amd64:1.0.0
+        resources:
+            requests:
+                cpu: "20m"
+                memory: "10Mi"
+        command:
+          - /cluster-proportional-autoscaler
+          - --namespace=kube-system
+          - --configmap=kube-dns-autoscaler
+          - --mode=linear
+          - --target=Deployment/kube-dns
+          # When cluster is using large nodes(with more cores), "coresPerReplica" should dominate.
+          # If using small nodes, "nodesPerReplica" should dominate.
+          - --default-params={"linear":{"coresPerReplica":256,"nodesPerReplica":10,"min":2}}
+          - --logtostderr=true
+          - --v=2
+
diff --git a/kubernetes/master/kube-addons.sls b/kubernetes/master/kube-addons.sls
index 9a6b065..99bbcef 100644
--- a/kubernetes/master/kube-addons.sls
+++ b/kubernetes/master/kube-addons.sls
@@ -26,6 +26,18 @@
     - dir_mode: 755
     - makedirs: True
 
+{% if master.addons.dns.get('autoscaler', True) %}
+
+/etc/kubernetes/addons/dns/kubedns-autoscaler.yaml:
+  file.managed:
+    - source: salt://kubernetes/files/kube-addons/dns/kubedns-autoscaler.yaml
+    - template: jinja
+    - group: root
+    - dir_mode: 755
+    - makedirs: True
+
+{% endif %}
+
 {% endif %}
 
 {%- if master.addons.dashboard.enabled %}
diff --git a/metadata/service/master/cluster.yml b/metadata/service/master/cluster.yml
index 6663bf2..70ea012 100644
--- a/metadata/service/master/cluster.yml
+++ b/metadata/service/master/cluster.yml
@@ -30,6 +30,7 @@
         dns:
           enabled: true
           replicas: 1
+          autoscaler: True
           domain: cluster.local
           server: 10.254.0.10
           dnsmasq:
diff --git a/metadata/service/master/single.yml b/metadata/service/master/single.yml
index 172f009..3ceebf6 100644
--- a/metadata/service/master/single.yml
+++ b/metadata/service/master/single.yml
@@ -26,6 +26,7 @@
         dns:
           enabled: true
           replicas: 1
+          autoscaler: True
           domain: cluster.local
           server: 10.254.0.10
           dnsmasq:
diff --git a/tests/pillar/master_cluster.sls b/tests/pillar/master_cluster.sls
index af37946..d9b326f 100644
--- a/tests/pillar/master_cluster.sls
+++ b/tests/pillar/master_cluster.sls
@@ -11,6 +11,7 @@
         enabled: true
         replicas: 1
         server: 10.254.0.10
+        autoscaler: True
       heapster_influxdb:
         enabled: true
         public_ip: 185.22.97.132