VOL-569: Create kubernetes deployment configuration for each voltha service

This update adds kubernetes deployment files for voltha-core, consul, and
the CLI. These files are not yet production-ready; for example, the consul
deployment will have to be augmented to support persistent storage. The
files do work and enable running these services (vcore, consul, and vcli)
on kubernetes.

Change-Id: Ic6708851fa560f381cb368759f26eb073c18d0e3
diff --git a/k8s/consul.yml b/k8s/consul.yml
new file mode 100644
index 0000000..86166f0
--- /dev/null
+++ b/k8s/consul.yml
@@ -0,0 +1,119 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: consul
+  labels:
+    name: consul
+spec:
+  clusterIP: None
+  ports:
+    - name: http
+      port: 8500
+      targetPort: 8500
+    - name: https
+      port: 8443
+      targetPort: 8443
+    - name: rpc
+      port: 8400
+      targetPort: 8400
+    - name: serflan-tcp
+      protocol: "TCP"
+      port: 8301
+      targetPort: 8301
+    - name: serflan-udp
+      protocol: "UDP"
+      port: 8301
+      targetPort: 8301
+    - name: serfwan-tcp
+      protocol: "TCP"
+      port: 8302
+      targetPort: 8302
+    - name: serfwan-udp
+      protocol: "UDP"
+      port: 8302
+      targetPort: 8302
+    - name: server
+      port: 8300
+      targetPort: 8300
+    - name: consuldns
+      port: 8600
+      targetPort: 8600
+  selector:
+    app: consul
+---
+apiVersion: apps/v1beta1
+kind: StatefulSet
+metadata:
+  name: consul
+spec:
+  serviceName: consul
+  replicas: 3
+  template:
+    metadata:
+      labels:
+        app: consul
+    spec:
+      affinity:
+        podAntiAffinity:
+          requiredDuringSchedulingIgnoredDuringExecution:
+            - labelSelector:
+                matchExpressions:
+                  - key: app
+                    operator: In
+                    values:
+                      - consul
+              topologyKey: kubernetes.io/hostname
+      terminationGracePeriodSeconds: 10
+      containers:
+        - name: consul
+          image: "consul:0.9.2"
+          env:
+            - name: POD_IP
+              valueFrom:
+                fieldRef:
+                  fieldPath: status.podIP
+            - name: NAMESPACE
+              valueFrom:
+                fieldRef:
+                  fieldPath: metadata.namespace
+          args:
+            - "agent"
+            - "-bind=0.0.0.0"
+            - "-bootstrap-expect=3"
+            - "-retry-join=consul-0.consul.$(NAMESPACE).svc.cluster.local"
+            - "-retry-join=consul-1.consul.$(NAMESPACE).svc.cluster.local"
+            - "-retry-join=consul-2.consul.$(NAMESPACE).svc.cluster.local"
+            - "-client=0.0.0.0"
+            - "-config-dir=/consul/config"
+            - "-datacenter=dc1"
+            - "-data-dir=/consul/data"
+            - "-domain=cluster.local"
+            - "-server"
+            - "-ui"
+            - "-disable-host-node-id"
+          lifecycle:
+            preStop:
+              exec:
+                command:
+                - /bin/sh
+                - -c
+                - consul leave
+          ports:
+            - containerPort: 8500
+              name: ui-port
+            - containerPort: 8400
+              name: alt-port
+            - containerPort: 53
+              name: udp-port
+            - containerPort: 8443
+              name: https-port
+            - containerPort: 8080
+              name: http-port
+            - containerPort: 8301
+              name: serflan
+            - containerPort: 8302
+              name: serfwan
+            - containerPort: 8600
+              name: consuldns
+            - containerPort: 8300
+              name: server
diff --git a/k8s/vcli.yml b/k8s/vcli.yml
new file mode 100644
index 0000000..1ef3bbd
--- /dev/null
+++ b/k8s/vcli.yml
@@ -0,0 +1,49 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: vcli
+  labels:
+    name: vcli
+spec:
+  ports:
+    - name: ssh
+      port: 5022
+      targetPort: 22
+  selector:
+    app: vcli
+---
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+  name: vcli
+spec:
+  replicas: 2
+  template:
+    metadata:
+      labels:
+        app: vcli
+    spec:
+      containers:
+        - name: vcli
+          image: "cord/vcli:latest"
+          env:
+            - name: POD_IP
+              valueFrom:
+                fieldRef:
+                  fieldPath: status.podIP
+            - name: NAMESPACE
+              valueFrom:
+                fieldRef:
+                  fieldPath: metadata.namespace
+          args:
+            - "/cli/cli/setup.sh"
+            - "-C consul:8500"
+            - "-g voltha:50555"
+            - "-s voltha:18880"
+            - "-G"
+          ports:
+            - containerPort: 22
+              name: ssh-port
+          imagePullPolicy: Never
+
+
diff --git a/k8s/vcore_for_consul.yml b/k8s/vcore_for_consul.yml
new file mode 100644
index 0000000..09b4c53
--- /dev/null
+++ b/k8s/vcore_for_consul.yml
@@ -0,0 +1,64 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: vcore
+  labels:
+    name: vcore
+spec:
+  clusterIP: None
+  ports:
+    - name: rest
+      port: 8880
+      targetPort: 8880
+    - name: mystery
+      port: 18880
+      targetPort: 18880
+    - name: grpc
+      port: 50556
+      targetPort: 50556
+  selector:
+    app: vcore
+---
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+  name: vcore
+spec:
+  replicas: 3
+  template:
+    metadata:
+      labels:
+        app: vcore
+    spec:
+      containers:
+        - name: voltha
+          image: "cord/voltha:latest"
+          env:
+            - name: POD_IP
+              valueFrom:
+                fieldRef:
+                  fieldPath: status.podIP
+            - name: NAMESPACE
+              valueFrom:
+                fieldRef:
+                  fieldPath: metadata.namespace
+          args:
+            - "voltha/voltha/main.py"
+            - "-v"
+            - "--consul=consul:8500"
+            - "--kafka=kafka"
+            - "--rest-port=8880"
+            - "--grpc-port=50556"
+            - "--interface=eth1"
+            - "--backend=consul"
+            - "--pon-subnet=172.29.19.0/24"
+          ports:
+            - containerPort: 8880
+              name: rest-port
+            - containerPort: 18880
+              name: mystery-port
+            - containerPort: 50556
+              name: grpc-port
+          imagePullPolicy: Never
+
+
diff --git a/k8s/vcore_for_etcd.yml b/k8s/vcore_for_etcd.yml
new file mode 100644
index 0000000..59bcfd0
--- /dev/null
+++ b/k8s/vcore_for_etcd.yml
@@ -0,0 +1,65 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: vcore
+  labels:
+    name: vcore
+spec:
+  clusterIP: None
+  ports:
+    - name: rest
+      port: 8880
+      targetPort: 8880
+    - name: mystery
+      port: 18880
+      targetPort: 18880
+    - name: grpc
+      port: 50556
+      targetPort: 50556
+  selector:
+    app: vcore
+---
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+  name: vcore
+spec:
+  replicas: 3
+  template:
+    metadata:
+      labels:
+        app: vcore
+    spec:
+      containers:
+        - name: voltha
+          image: "cord/voltha:latest"
+          env:
+            - name: POD_IP
+              valueFrom:
+                fieldRef:
+                  fieldPath: status.podIP
+            - name: NAMESPACE
+              valueFrom:
+                fieldRef:
+                  fieldPath: metadata.namespace
+          args:
+            - "voltha/voltha/main.py"
+            - "-v"
+            - "--consul=consul:8500"
+            - "--etcd=etcd:2379"
+            - "--kafka=kafka"
+            - "--rest-port=8880"
+            - "--grpc-port=50556"
+            - "--interface=eth1"
+            - "--backend=etcd"
+            - "--pon-subnet=172.29.19.0/24"
+          ports:
+            - containerPort: 8880
+              name: rest-port
+            - containerPort: 18880
+              name: mystery-port
+            - containerPort: 50556
+              name: grpc-port
+          imagePullPolicy: Never
+
+