Seed of deployment of log components

Deployment of: Logstash + ElasticSearch + Kubana with all the configuration files
Issue-ID:OOM-110

Change-Id: I1788485ccb283f0ec4dc8910479072a6cf034e5f
Signed-off-by: Itay Hassid <itay.hassid@amdocs.com>
diff --git a/kubernetes/log/templates/all-services.yaml b/kubernetes/log/templates/all-services.yaml
new file mode 100644
index 0000000..5f9412e
--- /dev/null
+++ b/kubernetes/log/templates/all-services.yaml
@@ -0,0 +1,49 @@
+apiVersion: v1
+kind: Service
+metadata:
+  labels:
+    app: elasticsearch
+  name: elasticsearch
+  namespace: {{ .Values.nsPrefix }}-log
+spec:
+  ports:
+  - name: http
+    port: 9200
+    targetPort: 9200
+    nodePort: {{ .Values.nodePortPrefix }}54
+  selector:
+    app: elasticsearch
+  type: NodePort
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: logstash
+  namespace: {{ .Values.nsPrefix }}-log
+  labels:
+    app: logstash
+spec:
+  ports:
+  - name: transport
+    port: 5044
+    targetPort: 5044
+  selector:
+    app: logstash
+---
+apiVersion: v1
+kind: Service
+metadata:
+  labels:
+    app: kibana
+  name: kibana
+  namespace: {{ .Values.nsPrefix }}-log
+spec:
+  ports:
+  - name: tcp-ks
+    port: 5601
+    targetPort: 5601
+    nodePort: {{ .Values.nodePortPrefix }}53
+  selector:
+    app: kibana
+  type: NodePort
+
diff --git a/kubernetes/log/templates/elasticsearch-deployment.yaml b/kubernetes/log/templates/elasticsearch-deployment.yaml
new file mode 100644
index 0000000..75df8a1
--- /dev/null
+++ b/kubernetes/log/templates/elasticsearch-deployment.yaml
@@ -0,0 +1,81 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  labels:
+    app: elasticsearch
+  name: elasticsearch
+  namespace: {{ .Values.nsPrefix }}-log
+spec:
+  selector:
+    matchLabels:
+      app: elasticsearch
+  template:
+    metadata:
+      labels:
+        app: elasticsearch
+      name: elasticsearch
+      annotations:
+        pod.beta.kubernetes.io/init-containers: '[
+          {
+              "command": ["sysctl", "-w", "vm.max_map_count=262144"],
+              "env": [
+                  {
+                      "name": "NAMESPACE",
+                      "valueFrom": {
+                          "fieldRef": {
+                              "apiVersion": "v1",
+                              "fieldPath": "metadata.namespace"
+                          }
+                      }
+                  }
+              ],
+              "securityContext": {
+                "privileged": true
+              },
+              "image": "{{ .Values.image.es_bb }}",
+              "imagePullPolicy": "{{ .Values.pullPolicy }}",
+              "name": "init-sysctl"
+          }
+          ]'
+    spec:
+      containers:
+      - name: elasticsearch
+        image: {{ .Values.image.elasticsearch}}
+        ports:
+        - containerPort: 9200
+          name: http
+          protocol: TCP
+        - containerPort: 9300
+          name: transport
+          protocol: TCP
+        readinessProbe:
+          tcpSocket:
+            port: 9200
+        volumeMounts:
+         - mountPath: /usr/share/elasticsearch/conf/
+           name: elasticsearch-conf
+         - mountPath: /usr/share/elasticsearch/data/
+           name: elasticsearch-data
+         - mountPath: /usr/share/elasticsearch/logs/
+           name: elasticsearch-logs
+      volumes:
+        - name: elasticsearch-data
+          persistentVolumeClaim:
+            claimName: elasticsearch-db
+        - name: elasticsearch-logs
+          hostPath:
+            path: /dockerdata-nfs/{{ .Values.nsPrefix }}/log/elasticsearch/logs
+        - name: elasticsearch-conf
+          configMap:
+            name: elasticsearch-configmap
+            items:
+            - key: elasticsearch.yml
+              path: elasticsearch.yml
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: elasticsearch-configmap
+  namespace: {{ .Values.nsPrefix }}-log
+data:
+{{ (.Files.Glob "resources/elasticsearch/conf/elasticsearch.yml").AsConfig | indent 2 }}
\ No newline at end of file
diff --git a/kubernetes/log/templates/kibana-deployment.yaml b/kubernetes/log/templates/kibana-deployment.yaml
new file mode 100644
index 0000000..f8070ef
--- /dev/null
+++ b/kubernetes/log/templates/kibana-deployment.yaml
@@ -0,0 +1,71 @@
+apiVersion: extensions/v1beta1 
+kind: Deployment
+metadata:
+  labels:
+    app: kibana
+  name: kibana
+  namespace: {{ .Values.nsPrefix }}-log
+spec:
+  selector:
+    matchLabels:
+      app: kibana
+  template:
+    metadata:
+      labels:
+        app: kibana
+      name: kibana
+      annotations:
+        pod.beta.kubernetes.io/init-containers: '[
+          {
+              "args": [
+                  "--container-name",
+                  "elasticsearch"
+              ],
+              "command": [
+                  "/root/ready.py"
+              ],
+              "env": [
+                  {
+                      "name": "NAMESPACE",
+                      "valueFrom": {
+                          "fieldRef": {
+                              "apiVersion": "v1",
+                              "fieldPath": "metadata.namespace"
+                          }
+                      }
+                  }
+              ],
+              "image": "{{ .Values.image.readiness }}",
+              "imagePullPolicy": "{{ .Values.pullPolicy }}",
+              "name": "kibana-readiness"
+          }
+          ]'
+    spec:
+      containers:
+      - name: kibana
+        image: {{ .Values.image.kibana }}
+        ports:
+        - containerPort: 5601
+          name: http
+          protocol: TCP
+        readinessProbe:
+          tcpSocket:
+            port: 5601
+        volumeMounts:
+         - name: kibana-conf
+           mountPath: /usr/share/kibana/config/      
+      volumes:
+        - name: kibana-conf
+          configMap:
+            name: kibana-configmap
+            items:
+            - key: kibana.yml
+              path: kibana.yml
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: kibana-configmap
+  namespace: {{ .Values.nsPrefix }}-log
+data:
+{{ (.Files.Glob "resources/kibana/conf/kibana.yml").AsConfig | indent 2 }}
\ No newline at end of file
diff --git a/kubernetes/log/templates/log-pv-pvc.yaml b/kubernetes/log/templates/log-pv-pvc.yaml
new file mode 100644
index 0000000..7e51e4c
--- /dev/null
+++ b/kubernetes/log/templates/log-pv-pvc.yaml
@@ -0,0 +1,30 @@
+apiVersion: v1
+kind: PersistentVolume
+metadata:
+  name: elasticsearch-db
+  namespace: "{{ .Values.nsPrefix }}-log"
+  labels:
+    name: elasticsearch-db
+spec:
+  capacity:
+    storage: 2Gi
+  accessModes:
+    - ReadWriteMany
+  persistentVolumeReclaimPolicy: Retain
+  hostPath:
+    path: /dockerdata-nfs/{{ .Values.nsPrefix }}/elasticsearch/data
+---
+kind: PersistentVolumeClaim
+apiVersion: v1
+metadata:
+  name: elasticsearch-db
+  namespace: "{{ .Values.nsPrefix }}-log"
+spec:
+  accessModes:
+    - ReadWriteMany
+  resources:
+    requests:
+      storage: 2Gi
+  selector:
+    matchLabels:
+      name: elasticsearch-db
diff --git a/kubernetes/log/templates/logstash-deployment.yaml b/kubernetes/log/templates/logstash-deployment.yaml
new file mode 100644
index 0000000..23d5906
--- /dev/null
+++ b/kubernetes/log/templates/logstash-deployment.yaml
@@ -0,0 +1,82 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  labels:
+    app: logstash
+  name: logstash
+  namespace: {{ .Values.nsPrefix }}-log 
+spec:
+  selector:
+    matchLabels:
+      app: logstash
+  template:
+    metadata:
+      labels:
+        app: logstash
+      name: logstash
+      annotations:
+        pod.beta.kubernetes.io/init-containers: '[
+          {
+              "args": [
+                  "--container-name",
+                  "elasticsearch"
+              ],
+              "command": [
+                  "/root/ready.py"
+              ],
+              "env": [
+                  {
+                      "name": "NAMESPACE",
+                      "valueFrom": {
+                          "fieldRef": {
+                              "apiVersion": "v1",
+                              "fieldPath": "metadata.namespace"
+                          }
+                      }
+                  }
+              ],
+              "image": "{{ .Values.image.readiness }}",
+              "imagePullPolicy": "{{ .Values.pullPolicy }}",
+              "name": "logstash-readiness"
+          }
+          ]'
+
+    spec:
+      containers:
+      - name: logstash
+        image: {{ .Values.image.logstash }}
+        ports:
+        - containerPort: 5044 
+          name: transport
+          protocol: TCP
+        readinessProbe:
+          tcpSocket:
+            port: 5044
+        volumeMounts:
+         - mountPath: /usr/share/logstash/config/
+           name: logstash-conf
+         - mountPath: /usr/share/logstash/pipeline/
+           name: logstash-pipeline
+      volumes:
+        - name: logstash-conf
+          configMap:
+            name: logstash-configmap
+            items:
+            - key: logstash.yml
+              path: logstash.yml
+        - name: logstash-pipeline
+          configMap:
+            name: logstash-configmap
+            items:
+            - key: onap-pipeline.conf
+              path: onap-pipeline.conf
+
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: logstash-configmap
+  namespace: {{ .Values.nsPrefix }}-log
+data:
+{{ (.Files.Glob "resources/logstash/conf/logstash.yml").AsConfig | indent 2 }}
+{{ (.Files.Glob "resources/logstash/pipeline/onap-pipeline.conf").AsConfig | indent 2 }}