VOL-1407: Perform end-to-end integration testing in the K8S environment
- Added support for testing in a single-node Kubernetes environment
  (affinity router not required)
- Added a preliminary README file (needs more work)

Change-Id: Ib617e1f6b6702eeeaa88a7ee9a7c6a82da8dd615
diff --git a/k8s/kafka.yml b/k8s/kafka.yml
index 88c3a39..a55bb3a 100644
--- a/k8s/kafka.yml
+++ b/k8s/kafka.yml
@@ -11,7 +11,6 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-
 apiVersion: v1
 kind: Service
 metadata:
@@ -59,13 +58,13 @@
               topologyKey: kubernetes.io/hostname
       containers:
       - name: kafka
-        image: wurstmeister/kafka:1.0.0
+        image: wurstmeister/kafka:2.11-2.0.1
         ports:
         - containerPort: 9092
         env:
-        - name: KAFKA_ADVERTISED_PORT
-          value: "9092"
+        - name: KAFKA_LISTENERS
+          value: PLAINTEXT://:9092
         - name: KAFKA_ZOOKEEPER_CONNECT
           value: zoo1:2181,zoo2:2181,zoo3:2181
-        - name: KAFKA_HEAP_OPTS
-          value: "-Xmx256M -Xms128M"
+        - name: KAFKA_AUTO_CREATE_TOPICS_ENABLE
+          value: "true"
diff --git a/k8s/single-node/README.md b/k8s/single-node/README.md
new file mode 100644
index 0000000..b1ba4df
--- /dev/null
+++ b/k8s/single-node/README.md
@@ -0,0 +1,39 @@
+## Running Voltha 2 in a Single-node Kubernetes Environment
+
+One way to do this is to set up the Vagrant environment for Voltha 1 by following the instructions
+in the BUILD.md file from the Voltha 1 repository at https://github.com/opencord/voltha.
+
+To build the Voltha 2 images, follow the instructions in voltha-go/python/adapters/README.md and
+ensure those images are available from within the Vagrant environment.
+
+Copy the appropriate Kubernetes manifests from the voltha-go/k8s directory.
+
+### Deploying Voltha 2
+
+To deploy Voltha 2 apply the following manifests (On a single node the affinity router is not required):
+```
+k8s/namespace.yml
+k8s/single-node/zookeeper.yml
+k8s/single-node/kafka.yml
+k8s/operator/etcd/cluster_role.yml
+k8s/operator/etcd/cluster_role_binding.yml
+k8s/operator/etcd/operator.yml
+k8s/single-node/etcd_cluster.yml
+k8s/single-node/rw-core.yml
+k8s/adapters-ponsim.yml
+k8s/single-node/ofagent.yml
+k8s/single-node/cli.yml
+```
+
+### Running PONsim
+
+To deploy the pods required to create PONsim devices, run ONOS,  and test EAP authentication:
+```
+k8s/genie-cni-plugin-1.8.yml
+k8s/single-node/freeradius-config.yml
+k8s/single-node/freeradius.yml
+k8s/onos.yml
+k8s/single-node/olt.yml
+k8s/single-node/onu.yml
+k8s/rg.yml
+```
diff --git a/k8s/single-node/freeradius-config.yml b/k8s/single-node/freeradius-config.yml
new file mode 100644
index 0000000..3379149
--- /dev/null
+++ b/k8s/single-node/freeradius-config.yml
@@ -0,0 +1,26 @@
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+apiVersion: v1
+data:
+  clients.conf: |
+    client 192.168.0.0/16 {
+      secret = SECRET
+    }
+  users: |
+    user Cleartext-Password := "password", MS-CHAP-Use-NTLM-Auth := 0
+
+kind: ConfigMap
+metadata:
+  name: freeradius-config
+  namespace: voltha
diff --git a/k8s/single-node/freeradius.yml b/k8s/single-node/freeradius.yml
new file mode 100644
index 0000000..7bfb39c
--- /dev/null
+++ b/k8s/single-node/freeradius.yml
@@ -0,0 +1,84 @@
+# Copyright 2019-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+apiVersion: v1
+kind: Service
+metadata:
+   name: freeradius
+   namespace: voltha
+   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
+  namespace: voltha
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: freeradius
+      annotations:
+        cni: "calico"
+    spec:
+      containers:
+        - name: freeradius
+          image: "tpdock/freeradius"
+          env:
+            - name: POD_IP
+              valueFrom:
+                fieldRef:
+                  fieldPath: status.podIP
+            - name: NAMESPACE
+              valueFrom:
+                fieldRef:
+                  fieldPath: metadata.namespace
+            - name: RADIUS_LISTEN_IP
+              value: "*"
+            - name: USERS_FILE
+              value: "/etc/raddb/users"
+            - name: RADIUS_CLIENTS
+              value: "SECRET@192.168.0.0/16"
+          ports:
+            - containerPort: 1812
+              name: radauth-port
+            - containerPort: 1813
+              name: radacc-port
+            - containerPort: 18120
+              name: radius-port
+          volumeMounts:
+            - name: freeradius-config
+              mountPath: /etc/raddb/users
+              subPath: users
+      volumes:
+        - name: freeradius-config
+          configMap:
+            name: freeradius-config
diff --git a/k8s/single-node/kafka.yml b/k8s/single-node/kafka.yml
index 4604676..a8a8d71 100644
--- a/k8s/single-node/kafka.yml
+++ b/k8s/single-node/kafka.yml
@@ -46,13 +46,13 @@
       terminationGracePeriodSeconds: 10
       containers:
       - name: kafka
-        image: wurstmeister/kafka:1.0.0
+        image: wurstmeister/kafka:2.11-2.0.1
         ports:
         - containerPort: 9092
         env:
-        - name: KAFKA_ADVERTISED_PORT
-          value: "9092"
+        - name: KAFKA_LISTENERS
+          value: PLAINTEXT://:9092
         - name: KAFKA_ZOOKEEPER_CONNECT
           value: zoo:2181
-        - name: KAFKA_HEAP_OPTS
-          value: "-Xmx256M -Xms128M"
+        - name: KAFKA_AUTO_CREATE_TOPICS_ENABLE
+          value: "true"
diff --git a/k8s/single-node/netcfg.json b/k8s/single-node/netcfg.json
new file mode 100644
index 0000000..1936397
--- /dev/null
+++ b/k8s/single-node/netcfg.json
@@ -0,0 +1,70 @@
+{
+ "apps": {
+   "org.opencord.aaa" : {
+         "AAA": {
+           "nasIp": "onos.voltha.svc.cluster.local",
+           "nasMac": "BA:6D:26:25:44:AA",
+           "radiusSecret": "SECRET",
+           "radiusIp": "freeradius.voltha.svc.cluster.local",
+           "radiusServerPort": "1812",
+           "radiusConnectionType": "socket",
+           "packetCustomizer": "sample"
+         }
+     },
+   "org.opencord.sadis" : {
+     "sadis" : {
+       "integration" : {
+           "cache" : {
+             "enabled" : true,
+             "maxsize" : 50,
+             "ttl" : "PT1m"
+           }
+       },
+       "entries" : [ {
+           "id" : "PSMO12345678",
+           "cTag" : 2,
+           "sTag" : 2,
+           "nasPortId" : "uni-128"
+           },{
+           "id" : "uni-129",
+           "cTag" : 2,
+           "sTag" : 2,
+           "nasPortId" : "uni-129"
+           },{
+           "id" : "uni-130",
+           "cTag" : 2,
+           "sTag" : 2,
+           "nasPortId" : "uni-130"
+           },{
+           "id" : "uni-131",
+           "cTag" : 2,
+           "sTag" : 2,
+           "nasPortId" : "uni-131"
+           }, {
+           "id" : "olt:50060",
+           "hardwareIdentifier" : "aa:bb:cc:dd:ee:ff",
+           "uplinkPort" : 65536
+           } ]
+     }
+   },
+   "org.opencord.dhcpl2relay" : {
+          "dhcpl2relay" : {
+              "dhcpServerConnectPoints" : [ "of:0000aabbccddeeff/65536" ],
+              "useOltUplinkForServerPktInOut" : true
+          }
+   }
+ },
+ "devices": {
+   "of:0000aabbccddeeff": {
+     "basic": {
+       "driver": "pmc-olt"
+     },
+     "accessDevice": {
+       "uplink": "0",
+       "vlan": "2"
+     }
+   }
+ },
+ "ports" : { 
+ }
+}
diff --git a/k8s/single-node/ofagent.yml b/k8s/single-node/ofagent.yml
new file mode 100644
index 0000000..ec603f5
--- /dev/null
+++ b/k8s/single-node/ofagent.yml
@@ -0,0 +1,47 @@
+# Copyright 2019-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+  name: ofagent
+  namespace: voltha
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: ofagent
+      annotations:
+        cni: "calico"
+    spec:
+      terminationGracePeriodSeconds: 10
+      containers:
+      - name: ofagent
+        image: volthacore/voltha-ofagent:rich
+        imagePullPolicy: Always
+        env:
+        - name: NAMESPACE
+          valueFrom:
+            fieldRef:
+              fieldPath: metadata.namespace
+        args:
+        - "/ofagent/ofagent/main.py"
+        - "-v"
+        - "--consul=consul.$(NAMESPACE).svc.cluster.local:8500"
+        - "--controller=onos:6653"
+        - "--grpc-endpoint=rw-core.$(NAMESPACE).svc.cluster.local:50057"
+        - "--enable-tls"
+        - "--key-file=/ofagent/pki/voltha.key"
+        - "--cert-file=/ofagent/pki/voltha.crt"
diff --git a/k8s/single-node/rw-core.yml b/k8s/single-node/rw-core.yml
index 7fd3848..b25d94a 100644
--- a/k8s/single-node/rw-core.yml
+++ b/k8s/single-node/rw-core.yml
@@ -67,6 +67,9 @@
             - "-kafka_cluster_host=kafka.$(NAMESPACE).svc.cluster.local"
             - "-kafka_cluster_port=9092"
             - "-rw_core_topic=rwcore"
+            - "-kv_store_data_prefix=service/voltha"
+            - "-in_competing_mode=false"
+            - "-timeout_long_request=5000"
             - "-log_level=0"
           ports:
             - containerPort: 50057