VOL-569: Create kubernetes deployment configuration for each voltha service
This update adds kubernetes deployment files for kafka/zookeeper.
Change-Id: I00d4d453de64dc4976d32a76c11f4b3fcb978d2c
diff --git a/k8s/kafka.yml b/k8s/kafka.yml
new file mode 100644
index 0000000..84f48cb
--- /dev/null
+++ b/k8s/kafka.yml
@@ -0,0 +1,51 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: kafka
+spec:
+ clusterIP: None
+ selector:
+ app: kafka
+ ports:
+ - protocol: TCP
+ port: 9092
+ targetPort: 9092
+---
+apiVersion: apps/v1beta1
+kind: StatefulSet
+metadata:
+ name: kafka
+spec:
+ serviceName: kafka
+ replicas: 3
+ selector:
+ matchLabels:
+ app: kafka
+ template:
+ metadata:
+ labels:
+ app: kafka
+ spec:
+ terminationGracePeriodSeconds: 10
+ affinity:
+ podAntiAffinity:
+ requiredDuringSchedulingIgnoredDuringExecution:
+ - labelSelector:
+ matchExpressions:
+ - key: app
+ operator: In
+ values:
+ - kafka
+ topologyKey: kubernetes.io/hostname
+ containers:
+ - name: kafka
+ image: wurstmeister/kafka:1.0.0
+ ports:
+ - containerPort: 9092
+ env:
+ - name: KAFKA_ADVERTISED_PORT
+ value: "9092"
+ - name: KAFKA_ZOOKEEPER_CONNECT
+ value: zoo1:2181,zoo2:2181,zoo3:2181
+ - name: KAFKA_HEAP_OPTS
+ value: "-Xmx256M -Xms128M"
diff --git a/k8s/vcore_for_consul.yml b/k8s/vcore_for_consul.yml
index 09b4c53..4052c80 100644
--- a/k8s/vcore_for_consul.yml
+++ b/k8s/vcore_for_consul.yml
@@ -34,10 +34,6 @@
- name: voltha
image: "cord/voltha:latest"
env:
- - name: POD_IP
- valueFrom:
- fieldRef:
- fieldPath: status.podIP
- name: NAMESPACE
valueFrom:
fieldRef:
@@ -45,8 +41,8 @@
args:
- "voltha/voltha/main.py"
- "-v"
- - "--consul=consul:8500"
- - "--kafka=kafka"
+ - "--consul=consul.$(NAMESPACE).svc.cluster.local:8500"
+ - "--kafka=kafka.$(NAMESPACE).svc.cluster.local"
- "--rest-port=8880"
- "--grpc-port=50556"
- "--interface=eth1"
diff --git a/k8s/vcore_for_etcd.yml b/k8s/vcore_for_etcd.yml
index 59bcfd0..35de8ab 100644
--- a/k8s/vcore_for_etcd.yml
+++ b/k8s/vcore_for_etcd.yml
@@ -34,10 +34,6 @@
- name: voltha
image: "cord/voltha:latest"
env:
- - name: POD_IP
- valueFrom:
- fieldRef:
- fieldPath: status.podIP
- name: NAMESPACE
valueFrom:
fieldRef:
@@ -45,9 +41,8 @@
args:
- "voltha/voltha/main.py"
- "-v"
- - "--consul=consul:8500"
- - "--etcd=etcd:2379"
- - "--kafka=kafka"
+ - "--etcd=etcd.$(NAMESPACE).svc.cluster.local:2379"
+ - "--kafka=kafka.$(NAMESPACE).svc.cluster.local"
- "--rest-port=8880"
- "--grpc-port=50556"
- "--interface=eth1"
diff --git a/k8s/zookeeper.yml b/k8s/zookeeper.yml
new file mode 100644
index 0000000..a469a61
--- /dev/null
+++ b/k8s/zookeeper.yml
@@ -0,0 +1,161 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: zoo1
+spec:
+ clusterIP: None
+ selector:
+ app: zookeeper-1
+ ports:
+ - name: client
+ port: 2181
+ targetPort: 2181
+ - name: follower
+ port: 2888
+ targetPort: 2888
+ - name: leader
+ port: 3888
+ targetPort: 3888
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: zoo2
+spec:
+ clusterIP: None
+ selector:
+ app: zookeeper-2
+ ports:
+ - name: client
+ port: 2181
+ targetPort: 2181
+ - name: follower
+ port: 2888
+ targetPort: 2888
+ - name: leader
+ port: 3888
+ targetPort: 3888
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: zoo3
+spec:
+ clusterIP: None
+ selector:
+ app: zookeeper-3
+ ports:
+ - name: client
+ port: 2181
+ targetPort: 2181
+ - name: follower
+ port: 2888
+ targetPort: 2888
+ - name: leader
+ port: 3888
+ targetPort: 3888
+---
+apiVersion: apps/v1beta1
+kind: StatefulSet
+metadata:
+ name: zookeeper1
+spec:
+ serviceName: zoo1
+ replicas: 1
+ selector:
+ matchLabels:
+ app: zookeeper-1
+ template:
+ metadata:
+ labels:
+ app: zookeeper-1
+ spec:
+ containers:
+ - name: zoo1
+ image: zookeeper:3.4.11
+ ports:
+ - containerPort: 2181
+ - containerPort: 2888
+ - containerPort: 3888
+ env:
+ - name: NAMESPACE
+ valueFrom:
+ fieldRef:
+ fieldPath: metadata.namespace
+ - name: ZOO_MY_ID
+ value: "1"
+ - name: ZOO_SERVERS
+ value: >
+ server.1=zookeeper1-0.zoo1.$(NAMESPACE).svc.cluster.local:2888:3888
+ server.2=zookeeper2-0.zoo2.$(NAMESPACE).svc.cluster.local:2888:3888
+ server.3=zookeeper3-0.zoo3.$(NAMESPACE).svc.cluster.local:2888:3888
+---
+apiVersion: apps/v1beta1
+kind: StatefulSet
+metadata:
+ name: zookeeper2
+spec:
+ serviceName: zoo2
+ replicas: 1
+ selector:
+ matchLabels:
+ app: zookeeper-2
+ template:
+ metadata:
+ labels:
+ app: zookeeper-2
+ spec:
+ containers:
+ - name: zoo2
+ image: zookeeper:3.4.11
+ ports:
+ - containerPort: 2181
+ - containerPort: 2888
+ - containerPort: 3888
+ env:
+ - name: NAMESPACE
+ valueFrom:
+ fieldRef:
+ fieldPath: metadata.namespace
+ - name: ZOO_MY_ID
+ value: "2"
+ - name: ZOO_SERVERS
+ value: >
+ server.1=zookeeper1-0.zoo1.$(NAMESPACE).svc.cluster.local:2888:3888
+ server.2=zookeeper2-0.zoo2.$(NAMESPACE).svc.cluster.local:2888:3888
+ server.3=zookeeper3-0.zoo3.$(NAMESPACE).svc.cluster.local:2888:3888
+---
+apiVersion: apps/v1beta1
+kind: StatefulSet
+metadata:
+ name: zookeeper3
+spec:
+ serviceName: zoo3
+ replicas: 1
+ selector:
+ matchLabels:
+ app: zookeeper-3
+ template:
+ metadata:
+ labels:
+ app: zookeeper-3
+ spec:
+ containers:
+ - name: zoo3
+ image: zookeeper:3.4.11
+ ports:
+ - containerPort: 2181
+ - containerPort: 2888
+ - containerPort: 3888
+ env:
+ - name: NAMESPACE
+ valueFrom:
+ fieldRef:
+ fieldPath: metadata.namespace
+ - name: ZOO_MY_ID
+ value: "3"
+ - name: ZOO_SERVERS
+ value: >
+ server.1=zookeeper1-0.zoo1.$(NAMESPACE).svc.cluster.local:2888:3888
+ server.2=zookeeper2-0.zoo2.$(NAMESPACE).svc.cluster.local:2888:3888
+ server.3=zookeeper3-0.zoo3.$(NAMESPACE).svc.cluster.local:2888:3888