enhance kubernetes addons

Change-Id: I8966e58718acab3a2c49567cb91b95b2326cf8ba
diff --git a/kubernetes/files/kube-addons/dashboard/dashboard-controller.yaml b/kubernetes/files/kube-addons/dashboard/dashboard-controller.yaml
index 562866b..a4236ec 100644
--- a/kubernetes/files/kube-addons/dashboard/dashboard-controller.yaml
+++ b/kubernetes/files/kube-addons/dashboard/dashboard-controller.yaml
@@ -3,10 +3,11 @@
 metadata:
   # Keep the name in sync with image version and
   # gce/coreos/kube-manifests/addons/dashboard counterparts
-  name: kubernetes-dashboard-v1.1.0
+  name: dashboard
   namespace: kube-system
   labels:
     k8s-app: kubernetes-dashboard
+    version: v1.4.0
     kubernetes.io/cluster-service: "true"
 spec:
   replicas: 1
@@ -17,10 +18,13 @@
       labels:
         k8s-app: kubernetes-dashboard
         kubernetes.io/cluster-service: "true"
+      annotations:
+        scheduler.alpha.kubernetes.io/critical-pod: ''
+        scheduler.alpha.kubernetes.io/tolerations: '[{"key":"CriticalAddonsOnly", "operator":"Exists"}]'
     spec:
       containers:
       - name: kubernetes-dashboard
-        image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.1.0
+        image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.4.0
         resources:
           # keep request = limit to keep this container in guaranteed class
           limits:
diff --git a/kubernetes/files/kube-addons/dns/skydns-rc.yaml b/kubernetes/files/kube-addons/dns/skydns-rc.yaml
index c7b7969..984bb5c 100644
--- a/kubernetes/files/kube-addons/dns/skydns-rc.yaml
+++ b/kubernetes/files/kube-addons/dns/skydns-rc.yaml
@@ -2,65 +2,79 @@
 apiVersion: v1
 kind: ReplicationController
 metadata:
-  name: kube-dns-v9
+  name: dns
   namespace: kube-system
   labels:
     k8s-app: kube-dns
-    version: v9
+    version: v20
     kubernetes.io/cluster-service: "true"
 spec:
   replicas: {{ master.addons.dns.replicas }}
   selector:
     k8s-app: kube-dns
-    version: v9
+    version: v20
   template:
     metadata:
       labels:
         k8s-app: kube-dns
-        version: v9
-        kubernetes.io/cluster-service: "true"
+        version: v20
+      annotations:
+        scheduler.alpha.kubernetes.io/critical-pod: ''
+        scheduler.alpha.kubernetes.io/tolerations: '[{"key":"CriticalAddonsOnly", "operator":"Exists"}]'
     spec:
       containers:
-      - name: etcd
-        image: gcr.io/google_containers/etcd:2.0.9
+      - name: kubedns
+        image: gcr.io/google_containers/kubedns-amd64:1.8
         resources:
           limits:
+            memory: 170Mi
+          requests:
             cpu: 100m
-            memory: 50Mi
-        command:
-        - /usr/local/bin/etcd
-        - -data-dir
-        - /var/etcd/data
-        - -listen-client-urls
-        - http://127.0.0.1:2379,http://127.0.0.1:4001
-        - -advertise-client-urls
-        - http://127.0.0.1:2379,http://127.0.0.1:4001
-        - -initial-cluster-token
-        - skydns-etcd
-        volumeMounts:
-        - name: etcd-storage
-          mountPath: /var/etcd/data
-      - name: kube2sky
-        image: gcr.io/google_containers/kube2sky:1.11
-        resources:
-          limits:
-            cpu: 100m
-            memory: 50Mi
+            memory: 70Mi
+        livenessProbe:
+          httpGet:
+            path: /healthz-kubedns
+            port: 8080
+            scheme: HTTP
+          initialDelaySeconds: 60
+          timeoutSeconds: 5
+          successThreshold: 1
+          failureThreshold: 5
+        readinessProbe:
+          httpGet:
+            path: /readiness
+            port: 8081
+            scheme: HTTP
+          initialDelaySeconds: 3
+          timeoutSeconds: 5
         args:
-        # command = "/kube2sky"
-        - -domain={{ master.addons.dns.domain }}
-      - name: skydns
-        image: gcr.io/google_containers/skydns:2015-10-13-8c72f8c
-        resources:
-          limits:
-            cpu: 100m
-            memory: 50Mi
+        # command = "/kube-dns"
+        - --domain={{ master.addons.dns.domain }}
+        - --dns-port=10053
+        - --kube-master-url=http://{{ master.apiserver.insecure_address }}:8080
+        ports:
+        - containerPort: 10053
+          name: dns-local
+          protocol: UDP
+        - containerPort: 10053
+          name: dns-tcp-local
+          protocol: TCP
+      - name: dnsmasq
+        image: gcr.io/google_containers/kube-dnsmasq-amd64:1.4
+        livenessProbe:
+          httpGet:
+            path: /healthz-dnsmasq
+            port: 8080
+            scheme: HTTP
+          initialDelaySeconds: 60
+          timeoutSeconds: 5
+          successThreshold: 1
+          failureThreshold: 5
         args:
-        # command = "/skydns"
-        - -machines=http://127.0.0.1:4001
-        - -addr=0.0.0.0:53
-        - -ns-rotate=false
-        - -domain={{ master.addons.dns.domain }}.
+        - --cache-size=1000
+        - --no-resolv
+        - --server=127.0.0.1#10053
+        - --log-facility=-
         ports:
         - containerPort: 53
           name: dns
@@ -68,33 +82,22 @@
         - containerPort: 53
           name: dns-tcp
           protocol: TCP
-        livenessProbe:
-          httpGet:
-            path: /healthz
-            port: 8080
-            scheme: HTTP
-          initialDelaySeconds: 30
-          timeoutSeconds: 5
-        readinessProbe:
-          httpGet:
-            path: /healthz
-            port: 8080
-            scheme: HTTP
-          initialDelaySeconds: 1
-          timeoutSeconds: 5
       - name: healthz
-        image: gcr.io/google_containers/exechealthz:1.0
+        image: gcr.io/google_containers/exechealthz-amd64:1.2
         resources:
           limits:
+            memory: 50Mi
+          requests:
             cpu: 10m
-            memory: 20Mi
+            memory: 50Mi
         args:
-        - -cmd=nslookup kubernetes.default.svc.{{ master.addons.dns.domain }} localhost >/dev/null
-        - -port=8080
+        - --cmd=nslookup kubernetes.default.svc.{{ master.addons.dns.domain }} 127.0.0.1 >/dev/null
+        - --url=/healthz-dnsmasq
+        - --cmd=nslookup kubernetes.default.svc.{{ master.addons.dns.domain }} 127.0.0.1:10053 >/dev/null
+        - --url=/healthz-kubedns
+        - --port=8080
+        - --quiet
         ports:
         - containerPort: 8080
           protocol: TCP
-      volumes:
-      - name: etcd-storage
-        emptyDir: {}
       dnsPolicy: Default  # Don't use cluster DNS.
\ No newline at end of file
diff --git a/kubernetes/files/kube-addons/kube-ui/kube-ui-address.yaml b/kubernetes/files/kube-addons/kube-ui/kube-ui-address.yaml
deleted file mode 100644
index f9f3749..0000000
--- a/kubernetes/files/kube-addons/kube-ui/kube-ui-address.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-{%- from "kubernetes/map.jinja" import master with context %}
-apiVersion: v1
-kind: Service
-metadata:
-  name: kube-ui-address
-  namespace: kube-system
-  labels:
-    k8s-app: kube-ui
-    kubernetes.io/cluster-service: "true"
-    kubernetes.io/name: "KubeUI"
-spec:
-  selector:
-    k8s-app: kube-ui
-  deprecatedPublicIPs: ["{{ master.addons.ui.public_ip }}"]
-  type: LoadBalancer
-  ports:
-  - port: 80
-    targetPort: 8080
\ No newline at end of file
diff --git a/kubernetes/files/kube-addons/kube-ui/kube-ui-endpoint.yaml b/kubernetes/files/kube-addons/kube-ui/kube-ui-endpoint.yaml
deleted file mode 100644
index 9b22ebc..0000000
--- a/kubernetes/files/kube-addons/kube-ui/kube-ui-endpoint.yaml
+++ /dev/null
@@ -1,17 +0,0 @@
-{%- from "kubernetes/map.jinja" import master with context %}
-apiVersion: v1
-kind: Endpoints
-metadata:
-  name: kube-ui
-  namespace: kube-system
-  labels:
-    k8s-app: kube-ui
-    kubernetes.io/cluster-service: "true"
-    kubernetes.io/name: "KubeUI"
-subsets:
-  - addresses:
-    - ip: {{ master.addons.ui.public_ip }}
-
-    ports:
-    - port: 8080
-      protocol: TCP
\ No newline at end of file
diff --git a/kubernetes/files/kube-addons/kube-ui/kube-ui-rc.yaml b/kubernetes/files/kube-addons/kube-ui/kube-ui-rc.yaml
deleted file mode 100644
index 9c43389..0000000
--- a/kubernetes/files/kube-addons/kube-ui/kube-ui-rc.yaml
+++ /dev/null
@@ -1,36 +0,0 @@
-apiVersion: v1
-kind: ReplicationController
-metadata:
-  name: kube-ui-v4
-  namespace: kube-system
-  labels:
-    k8s-app: kube-ui
-    version: v4
-    kubernetes.io/cluster-service: "true"
-spec:
-  replicas: 1
-  selector:
-    k8s-app: kube-ui
-    version: v4
-  template:
-    metadata:
-      labels:
-        k8s-app: kube-ui
-        version: v4
-        kubernetes.io/cluster-service: "true"
-    spec:
-      containers:
-      - name: kube-ui
-        image: gcr.io/google_containers/kube-ui:v4
-        resources:
-          limits:
-            cpu: 100m
-            memory: 50Mi
-        ports:
-        - containerPort: 8080
-        livenessProbe:
-          httpGet:
-            path: /
-            port: 8080
-          initialDelaySeconds: 30
-          timeoutSeconds: 5
\ No newline at end of file
diff --git a/kubernetes/files/kube-addons/kube-ui/kube-ui-svc.yaml b/kubernetes/files/kube-addons/kube-ui/kube-ui-svc.yaml
deleted file mode 100644
index 876be68..0000000
--- a/kubernetes/files/kube-addons/kube-ui/kube-ui-svc.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-apiVersion: v1
-kind: Service
-metadata:
-  name: kube-ui
-  namespace: kube-system
-  labels:
-    k8s-app: kube-ui
-    kubernetes.io/cluster-service: "true"
-    kubernetes.io/name: "KubeUI"
-spec:
-  ports:
-  - port: 80
-    targetPort: 8080
\ No newline at end of file
diff --git a/kubernetes/master/init.sls b/kubernetes/master/init.sls
index a1e2376..cff687f 100644
--- a/kubernetes/master/init.sls
+++ b/kubernetes/master/init.sls
@@ -17,3 +17,4 @@
 - kubernetes.master.glusterfs
 {%- endif %}
 - kubernetes.master.controller
+- kubernetes.master.setup
\ No newline at end of file
diff --git a/kubernetes/master/kube-addons.sls b/kubernetes/master/kube-addons.sls
index 2996916..d1b4b37 100644
--- a/kubernetes/master/kube-addons.sls
+++ b/kubernetes/master/kube-addons.sls
@@ -28,43 +28,7 @@
 
 {% endif %}
 
-{%- if master.addons.ui.enabled %}
-
-{%- if master.version == "v1.1.1" %}
-
-/etc/kubernetes/addons/kube-ui/kube-ui-svc.yaml:
-  file.managed:
-    - source: salt://kubernetes/files/kube-addons/kube-ui/kube-ui-svc.yaml
-    - template: jinja
-    - group: root
-    - dir_mode: 755
-    - makedirs: True
-
-/etc/kubernetes/addons/kube-ui/kube-ui-rc.yaml:
-  file.managed:
-    - source: salt://kubernetes/files/kube-addons/kube-ui/kube-ui-rc.yaml
-    - template: jinja
-    - group: root
-    - dir_mode: 755
-    - makedirs: True
-
-/etc/kubernetes/addons/kube-ui/kube-ui-address.yaml:
-  file.managed:
-    - source: salt://kubernetes/files/kube-addons/kube-ui/kube-ui-address.yaml
-    - template: jinja
-    - group: root
-    - dir_mode: 755
-    - makedirs: True
-
-/etc/kubernetes/addons/kube-ui/kube-ui-endpoint.yaml:
-  file.managed:
-    - source: salt://kubernetes/files/kube-addons/kube-ui/kube-ui-endpoint.yaml
-    - template: jinja
-    - group: root
-    - dir_mode: 755
-    - makedirs: True
-
-{% endif %}
+{%- if master.addons.dashboard.enabled %}
 
 /etc/kubernetes/addons/dashboard/dashboard-service.yaml:
   file.managed:
diff --git a/kubernetes/master/setup.sls b/kubernetes/master/setup.sls
new file mode 100644
index 0000000..c1505bf
--- /dev/null
+++ b/kubernetes/master/setup.sls
@@ -0,0 +1,15 @@
+{%- from "kubernetes/map.jinja" import master with context %}
+{%- if master.enabled %}
+
+{%- for addon_name, addon in master.addons.iteritems() %}
+{%- if addon.enabled %}
+
+kubernetes_addons_{{ addon_name }}:
+  cmd.run:
+    - name: |
+        hyperkube kubectl create -f /etc/kubernetes/addons/{{ addon_name }}
+    - unless: "hyperkube kubectl get rc {{ addon_name }} --namespace=kube-system"
+
+{%- endif %}
+{%- endfor %}
+{%- endif %}
\ No newline at end of file
diff --git a/tests/pillar/master_cluster.sls b/tests/pillar/master_cluster.sls
index 35ad288..f951eb3 100644
--- a/tests/pillar/master_cluster.sls
+++ b/tests/pillar/master_cluster.sls
@@ -12,7 +12,7 @@
       heapster_influxdb:
         enabled: true
         public_ip: 185.22.97.132
-      ui:
+      dashboard:
         enabled: true
         public_ip: 185.22.97.131
     admin: