add netchecker addon

Change-Id: I3e7c20323efdc4a05377782a69109eea5c9ac6b1
diff --git a/README.rst b/README.rst
index 6ff7840..98785ed 100644
--- a/README.rst
+++ b/README.rst
@@ -32,7 +32,7 @@
             cni:
               image: calico/cni
 
-Enable helm-tiller addons
+Enable helm-tiller addon
 
 .. code-block:: yaml
 
@@ -43,6 +43,19 @@
             helm:
               enabled: true
 
+Enable netchecker addon
+
+.. code-block:: yaml
+
+    parameters:
+      kubernetes:
+        master:
+          namespace:
+            netchecker:
+              enabled: true
+          addons:
+            netchecker:
+              enabled: true
 
 Pass aditional parameters to daemons:
 
diff --git a/kubernetes/files/kube-addons/netchecker/netchecker-agent.yml b/kubernetes/files/kube-addons/netchecker/netchecker-agent.yml
new file mode 100644
index 0000000..52d0443
--- /dev/null
+++ b/kubernetes/files/kube-addons/netchecker/netchecker-agent.yml
@@ -0,0 +1,28 @@
+{%- from "kubernetes/map.jinja" import master with context %}
+apiVersion: extensions/v1beta1
+kind: DaemonSet
+metadata:
+  labels:
+    app: netchecker-agent
+  name: netchecker-agent
+  namespace: {{ master.addons.netchecker.namespace }}
+spec:
+  template:
+    metadata:
+      name: netchecker-agent
+      labels:
+        app: netchecker-agent
+    spec:
+      containers:
+        - name: netchecker-agent
+          image: {{ master.addons.netchecker.agent_image }}
+          env:
+            - name: MY_POD_NAME
+              valueFrom:
+                fieldRef:
+                  fieldPath: metadata.name
+          args:
+            - "-v=5"
+            - "-alsologtostderr=true"
+            - "-serverendpoint=netchecker:{{ master.addons.netchecker.port }}"
+            - "-reportinterval={{ master.addons.netchecker.interval }}"
diff --git a/kubernetes/files/kube-addons/netchecker/netchecker-server.yml b/kubernetes/files/kube-addons/netchecker/netchecker-server.yml
new file mode 100644
index 0000000..88170f1
--- /dev/null
+++ b/kubernetes/files/kube-addons/netchecker/netchecker-server.yml
@@ -0,0 +1,23 @@
+{%- from "kubernetes/map.jinja" import master with context %}
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  name: netchecker-server
+  namespace: {{ master.addons.netchecker.namespace }}
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: netchecker-server
+    spec:
+      containers:
+        - name: netchecker-server
+          image: {{ master.addons.netchecker.server_image }}
+          ports:
+            - containerPort: {{ master.addons.netchecker.port }}
+          args:
+            - "-v=5"
+            - "-logtostderr"
+            - "-kubeproxyinit"
+            - "-endpoint=0.0.0.0:{{ master.addons.netchecker.port }}"
diff --git a/kubernetes/files/kube-addons/netchecker/netchecker-svc.yml b/kubernetes/files/kube-addons/netchecker/netchecker-svc.yml
new file mode 100644
index 0000000..309d61f
--- /dev/null
+++ b/kubernetes/files/kube-addons/netchecker/netchecker-svc.yml
@@ -0,0 +1,14 @@
+{%- from "kubernetes/map.jinja" import master with context %}
+kind: Service
+apiVersion: "v1"
+metadata:
+  name: netchecker
+  namespace: {{ master.addons.netchecker.namespace }}
+spec:
+  selector:
+    app: netchecker-server
+  ports:
+    - protocol: "TCP"
+      port: {{ master.addons.netchecker.port }}
+      targetPort: {{ master.addons.netchecker.port }}
+  type: NodePort
diff --git a/kubernetes/master/kube-addons.sls b/kubernetes/master/kube-addons.sls
index af5bd98..e7f5324 100644
--- a/kubernetes/master/kube-addons.sls
+++ b/kubernetes/master/kube-addons.sls
@@ -19,6 +19,23 @@
 
 {% endif %}
 
+{%- if master.addons.netchecker.enabled %}
+
+{%- for resource in ['svc', 'server', 'agent'] %}
+
+/etc/kubernetes/addons/netchecker/netchecker-{{ resource }}.yml:
+  file.managed:
+    - source: salt://kubernetes/files/kube-addons/netchecker/netchecker-{{ resource }}.yml
+    - template: jinja
+    - group: root
+    - dir_mode: 755
+    - makedirs: True
+
+{%- endfor %}
+
+{% endif %}
+
+
 {%- if master.addons.dns.enabled %}
 
 /etc/kubernetes/addons/dns/kubedns-svc.yaml:
diff --git a/metadata/service/master/cluster.yml b/metadata/service/master/cluster.yml
index 96b56e3..6df097e 100644
--- a/metadata/service/master/cluster.yml
+++ b/metadata/service/master/cluster.yml
@@ -46,6 +46,13 @@
         helm:
           enabled: False
           tiller_image: gcr.io/kubernetes-helm/tiller:v2.2.3
+        netchecker:
+          enabled: False
+          interval: 60
+          namespace: netchecker
+          port: 80
+          agent_image: quay.io/l23network/k8s-netchecker-agent:v1.0
+          server_image: quay.io/l23network/k8s-netchecker-server:v1.0
       token:
         admin: ${_param:kubernetes_admin_token}
         kubelet: ${_param:kubernetes_kubelet_token}
diff --git a/tests/pillar/master_cluster.sls b/tests/pillar/master_cluster.sls
index 83c8fd3..36cf4d5 100644
--- a/tests/pillar/master_cluster.sls
+++ b/tests/pillar/master_cluster.sls
@@ -19,8 +19,10 @@
         enabled: true
         public_ip: 185.22.97.131
       helm:
-        enabled: False
+        enabled: true
         tiller_image: gcr.io/kubernetes-helm/tiller:v2.2.3
+      netchecker:
+        enabled: true
     admin:
       password: password
       username: admin
@@ -66,6 +68,8 @@
     version: v1.2.4
     namespace:
       kube-system:
-        enabled: True
+        enabled: true
+      netchecker:
+        enabled: true
     hyperkube:
       hash: hnsj0XqABgrSww7Nqo7UVTSZLJUt2XRd