VOL-613 : PON simulator kubernetes integration

- Added onos/freeradius deployment templates
- Added olt, onu and rg deployment templates
- Added cni annotation to all templates to work with CNI Genie
- Added more instructions in the README

Amendments:

- Removed cni annotation from the service block

Change-Id: I63c28488f9cfcbfc2701391e67874cb8d998528b
diff --git a/k8s/README.md b/k8s/README.md
index 01d83e9..35df47c 100644
--- a/k8s/README.md
+++ b/k8s/README.md
@@ -1,3 +1,91 @@
+# How to set up networking
+
+## Basic requirement
+
+When Kubernetes is first deployed, you are required to setup networking by installing Weave.  
+This ensures the proper deployment of containers such as kube-dns.
+
+The most common network plugin used is Weave which can be deployed by issuing the following command:
+
+```
+kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
+```
+## Support for multiple network interfaces 
+
+When a container is deployed in Kubernetes, a single network interface is assigned to the container.
+
+Some containers may require multiple interfaces, thus the CNI Genie package can provide that 
+capability.
+
+It can be installed by issuing the command:
+
+```
+kubectl apply -f https://raw.githubusercontent.com/Huawei-PaaS/CNI-Genie/master/conf/1.8/genie.yaml
+```
+
+Once CNI Genie is installed, you will need to modify your k8s templates to include the necessary
+annotations statement.  This statement allows you specify 1 or more network plugin types.
+
+e.g.
+```
+  ...
+  template:
+    metadata:
+      labels:
+        app: your-app-name
+      annotations:
+        cni: "weave"
+    spec:
+    ...
+
+```
+
+If you wish to only use weave for your container, you would modify the template as described above.
+
+If you wish to include 2 or more interfaces, you can do so by changing the "cni" string with a 
+list of comma-separated network plugins.  
+
+e.g.
+
+``` /etc/cni/net.d/10-mybridge.conf
+  ...
+  template:
+    metadata:
+      labels:
+        app: your-app-name
+      annotations:
+        cni: "weave,mybridge,myvlan"
+    spec:
+    ...
+```
+
+Here "myvlan" and "mybridge" refer to cni templates that you would have previously defined on 
+each host of your cluster.  
+
+e.g.
+
+```
+/etc/cni/net.d/10-mybridge.conf
+
+{
+    "name": "mybridge",
+    "type": "bridge",
+    "bridge": "mybridge",
+    "isGateway": true,
+    "ipMask": true,
+    "ipam": {
+      "type": "host-local",
+      "subnet": "10.11.12.0/24",
+      "routes": [
+        { "dst": "0.0.0.0/0" }
+      ]
+    }
+}
+```
+
+Refer to the Kubernetes documentation for more information on the supported network plugins and 
+how to configure them.
+
 # How to set up Ingress into Services deployed on a Kubernetes Cluster
 
 1. Create an ingress controller and then an Ingress resource:
diff --git a/k8s/consul.yml b/k8s/consul.yml
index a750a97..34b1fc8 100644
--- a/k8s/consul.yml
+++ b/k8s/consul.yml
@@ -53,6 +53,8 @@
     metadata:
       labels:
         app: consul
+      annotations:
+        cni: "weave"
     spec:
       affinity:
         podAntiAffinity:
diff --git a/k8s/data/clients.conf b/k8s/data/clients.conf
new file mode 100644
index 0000000..c63eca8
--- /dev/null
+++ b/k8s/data/clients.conf
@@ -0,0 +1,3 @@
+client  10.38.0.0/12 {
+ secret = SECRET
+}
diff --git a/k8s/data/users b/k8s/data/users
new file mode 100644
index 0000000..1e84143
--- /dev/null
+++ b/k8s/data/users
@@ -0,0 +1 @@
+user Cleartext-Password := "password", MS-CHAP-Use-NTLM-Auth := 0
diff --git a/k8s/envoy_for_consul.yml b/k8s/envoy_for_consul.yml
index 1d9f1e0..5b6e7e4 100644
--- a/k8s/envoy_for_consul.yml
+++ b/k8s/envoy_for_consul.yml
@@ -32,6 +32,8 @@
     metadata:
       labels:
         app: voltha
+      annotations:
+        cni: "weave"
     spec:
       containers:
         - name: voltha
diff --git a/k8s/fluentd.yml b/k8s/fluentd.yml
index 1a7ec0f..0e4839b 100644
--- a/k8s/fluentd.yml
+++ b/k8s/fluentd.yml
@@ -32,6 +32,8 @@
     metadata:
       labels:
         app: fluentdactv
+      annotations:
+        cni: "weave"
     spec:
       terminationGracePeriodSeconds: 10
       affinity:
@@ -92,6 +94,8 @@
     metadata:
       labels:
         app: fluentdstby
+      annotations:
+        cni: "weave"
     spec:
       terminationGracePeriodSeconds: 10
       affinity:
@@ -148,6 +152,8 @@
     metadata:
       labels:
         app: fluentd
+      annotations:
+        cni: "weave"
     spec:
       terminationGracePeriodSeconds: 10
       affinity:
diff --git a/k8s/freeradius.yml b/k8s/freeradius.yml
new file mode 100644
index 0000000..55eb926
--- /dev/null
+++ b/k8s/freeradius.yml
@@ -0,0 +1,66 @@
+apiVersion: v1
+kind: Service
+metadata:
+   name: freeradius
+   labels:
+     name: freeradius
+spec:
+  clusterIP: None
+  ports:
+    - name: radius-auth
+      protocol: UDP
+      port: 1812
+      targetPort: 1812
+    - name: radius-acc
+      protocol: UDP
+      port: 1813
+      targetPort: 1813
+    - name: radius
+      port: 18120
+      targetPort: 18120
+  selector:
+    app: freeradius
+---
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+  name: freeradius
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: freeradius
+      annotations:
+        cni: "weave"
+    spec:
+      containers:
+        - name: freeradius
+          image: "marcelmaatkamp/freeradius"
+          env:
+            - name: POD_IP
+              valueFrom:
+                fieldRef:
+                  fieldPath: status.podIP
+            - name: NAMESPACE
+              valueFrom:
+                fieldRef:
+                  fieldPath: metadata.namespace
+          ports:
+            - containerPort: 1812
+              name: radauth-port
+            - containerPort: 1813
+              name: radacc-port
+            - containerPort: 18120
+              name: radius-port
+          volumeMounts:
+            - name: freeradius-config
+              mountPath: /etc/raddb/clients.conf
+              subPath: clients.conf
+            - name: freeradius-config
+              mountPath: /etc/raddb/users
+              subPath: users
+      volumes:
+        - name: freeradius-config
+          configMap:
+            name: freeradius-config
diff --git a/k8s/kafka.yml b/k8s/kafka.yml
index 84f48cb..a8db827 100644
--- a/k8s/kafka.yml
+++ b/k8s/kafka.yml
@@ -25,6 +25,8 @@
     metadata:
       labels:
         app: kafka
+      annotations:
+        cni: "weave"
     spec:
       terminationGracePeriodSeconds: 10
       affinity:
diff --git a/k8s/ofagent.yml b/k8s/ofagent.yml
index 70e78a8..7598d0b 100644
--- a/k8s/ofagent.yml
+++ b/k8s/ofagent.yml
@@ -8,6 +8,8 @@
     metadata:
       labels:
         app: ofagent
+      annotations:
+        cni: "weave"
     spec:
       terminationGracePeriodSeconds: 10
       affinity:
diff --git a/k8s/olt.yml b/k8s/olt.yml
new file mode 100644
index 0000000..9093c3b
--- /dev/null
+++ b/k8s/olt.yml
@@ -0,0 +1,61 @@
+apiVersion: v1
+kind: Service
+metadata:
+   name: olt
+   labels:
+     name: olt
+spec:
+  ports:
+    - name: grpc
+      port: 50060
+      targetPort: 50060
+  selector:
+    app: olt
+---
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+  name: olt
+spec:
+   replicas: 1
+   template:
+     metadata:
+       labels:
+         app: olt
+       annotations:
+         cni: "weave"
+     spec:
+       containers:
+         - name: olt
+           image: "voltha-ponsim:latest"
+           env:
+             - name: POD_IP
+               valueFrom:
+                 fieldRef:
+                   fieldPath: status.podIP
+             - name: NAMESPACE
+               valueFrom:
+                 fieldRef:
+                   fieldPath: metadata.namespace
+
+           args:
+             - "/app/ponsim"
+             - "-device_type"
+             - "OLT"
+             - "-onus"
+             - "3"
+             - "-internal_if"
+             - "eth0"
+             - "-external_if"
+             - "eth0"
+             - "-vcore_endpoint"
+             - "vcore"
+             - "-promiscuous"
+             - "-fluentd"
+             - "fluentd.$(NAMESPACE).svc.cluster.local:24224"
+
+           ports:
+            - containerPort: 50060
+              name: grpc-port
+
+           imagePullPolicy: Never
diff --git a/k8s/onos.yml b/k8s/onos.yml
new file mode 100644
index 0000000..5843a3a
--- /dev/null
+++ b/k8s/onos.yml
@@ -0,0 +1,55 @@
+apiVersion: v1
+kind: Service
+metadata:
+   name: onos
+   labels:
+     name: onos
+spec:
+  ports:
+    - name: ssh
+      port: 8101
+      targetPort: 8101
+    - name: of
+      port: 6653
+      targetPort: 6653
+    - name: ui
+      port: 8181
+      targetPort: 8181
+  selector:
+    app: onos
+---
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+  name: onos
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: onos
+      annotations:
+        cni: "weave"
+    spec:
+      containers:
+        - name: onos
+          image: "voltha-onos:latest"
+          env:
+            - name: POD_IP
+              valueFrom:
+                fieldRef:
+                  fieldPath: status.podIP
+            - name: NAMESPACE
+              valueFrom:
+                fieldRef:
+                  fieldPath: metadata.namespace
+            - name: ONOS_APPS
+              value: "drivers,openflow-base"
+          ports:
+            - containerPort: 8101
+              name: ssh-port
+            - containerPort: 6653
+              name: of-port
+            - containerPort: 8181
+              name: ui-port
+          imagePullPolicy: Never
diff --git a/k8s/onu.yml b/k8s/onu.yml
new file mode 100644
index 0000000..cfd3763
--- /dev/null
+++ b/k8s/onu.yml
@@ -0,0 +1,61 @@
+apiVersion: v1
+kind: Service
+metadata:
+   name: onu
+   labels:
+     name: onu
+spec:
+  ports:
+    - name: grpc
+      port: 50061
+      targetPort: 50061
+  selector:
+    app: onu
+---
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+  name: onu
+spec:
+   replicas: 3
+   template:
+     metadata:
+       labels:
+         app: onu
+       annotations:
+         cni: "weave,pon0"
+     spec:
+       containers:
+         - name: onu
+           image: "voltha-ponsim:latest"
+           env:
+             - name: POD_IP
+               valueFrom:
+                 fieldRef:
+                   fieldPath: status.podIP
+             - name: NAMESPACE
+               valueFrom:
+                 fieldRef:
+                   fieldPath: metadata.namespace
+
+           args:
+             - "/app/ponsim"
+             - "-device_type"
+             - "ONU"
+             - "-parent_addr"
+             - "olt"
+             - "-grpc_port"
+             - "50061"
+             - "-internal_if"
+             - "eth0"
+             - "-external_if"
+             - "eth1"
+             - "-promiscuous"
+             - "-fluentd"
+             - "fluentd.$(NAMESPACE).svc.cluster.local:24224"
+
+           ports:
+            - containerPort: 50061
+              name: grpc-port
+
+           imagePullPolicy: Never
diff --git a/k8s/rg.yml b/k8s/rg.yml
new file mode 100644
index 0000000..27dd346
--- /dev/null
+++ b/k8s/rg.yml
@@ -0,0 +1,27 @@
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+  name: rg
+spec:
+   replicas: 1
+   template:
+     metadata:
+       labels:
+         app: rg
+       annotations:
+         cni: "pon0"
+     spec:
+       containers:
+         - name: rg
+           image: "voltha-tester:latest"
+           env:
+             - name: POD_IP
+               valueFrom:
+                 fieldRef:
+                   fieldPath: status.podIP
+             - name: NAMESPACE
+               valueFrom:
+                 fieldRef:
+                   fieldPath: metadata.namespace
+           command: [ "/bin/bash", "-c", "trap : TERM INT; sleep infinity & wait" ]
+           imagePullPolicy: Never
diff --git a/k8s/vcli.yml b/k8s/vcli.yml
index 9debaf4..bcb7b20 100644
--- a/k8s/vcli.yml
+++ b/k8s/vcli.yml
@@ -22,6 +22,8 @@
     metadata:
       labels:
         app: vcli
+      annotations:
+        cni: "weave"
     spec:
       containers:
         - name: vcli
diff --git a/k8s/vcore_for_consul.yml b/k8s/vcore_for_consul.yml
index 3784faf..260c21e 100644
--- a/k8s/vcore_for_consul.yml
+++ b/k8s/vcore_for_consul.yml
@@ -29,6 +29,8 @@
     metadata:
       labels:
         app: vcore
+      annotations:
+        cni: "weave"
     spec:
       containers:
       - name: voltha
@@ -56,4 +58,5 @@
         - "--grpc-port=50556"
         - "--interface=eth1"
         - "--backend=consul"
-        - "--pon-subnet=172.29.19.0/24"
+        - "--pon-subnet=10.38.0.0/12"
+        - "--ponsim-comm=grpc"
\ No newline at end of file
diff --git a/k8s/vcore_for_etcd.yml b/k8s/vcore_for_etcd.yml
index 4ae89b3..edb6a29 100644
--- a/k8s/vcore_for_etcd.yml
+++ b/k8s/vcore_for_etcd.yml
@@ -29,6 +29,8 @@
     metadata:
       labels:
         app: vcore
+      annotations:
+        cni: "weave"
     spec:
       containers:
         - name: voltha
@@ -48,7 +50,8 @@
             - "--grpc-port=50556"
             - "--interface=eth1"
             - "--backend=etcd"
-            - "--pon-subnet=172.29.19.0/24"
+            - "--pon-subnet=10.38.0.0/12"
+            - "--ponsim-comm=grpc"
           ports:
             - containerPort: 8880
               name: rest-port
diff --git a/k8s/zookeeper.yml b/k8s/zookeeper.yml
index a469a61..3ef7b3d 100644
--- a/k8s/zookeeper.yml
+++ b/k8s/zookeeper.yml
@@ -69,6 +69,8 @@
     metadata:
       labels:
         app: zookeeper-1
+      annotations:
+        cni: "weave"
     spec:
       containers:
       - name: zoo1
@@ -104,6 +106,8 @@
     metadata:
       labels:
         app: zookeeper-2
+      annotations:
+        cni: "weave"
     spec:
       containers:
       - name: zoo2
@@ -139,6 +143,8 @@
     metadata:
       labels:
         app: zookeeper-3
+      annotations:
+        cni: "weave"
     spec:
       containers:
       - name: zoo3