Run all components in one namespace
[oom.git] / kubernetes / log / templates / elasticsearch-deployment.yaml
index 74ab921..2b596d2 100644 (file)
@@ -4,8 +4,8 @@ kind: Deployment
 metadata:
   labels:
     app: elasticsearch
-  name: elasticsearch
-  namespace: {{ .Values.nsPrefix }}-log
+  name: log-elasticsearch
+  namespace: {{ .Values.nsPrefix }}
 spec:
   selector:
     matchLabels:
@@ -14,13 +14,18 @@ spec:
     metadata:
       labels:
         app: elasticsearch
-      name: elasticsearch
+      name: log-elasticsearch
     spec:
       initContainers:
       - command:
-        - sysctl
-        - -w
-        - vm.max_map_count=262144
+        - /bin/sh
+        - -c
+        - |
+          sysctl -w vm.max_map_count=262144
+          mkdir -p /logroot/elasticsearch/logs
+          mkdir -p /logroot/elasticsearch/data
+          chmod -R 777 /logroot/elasticsearch
+          chown -R root:root /logroot
         env:
         - name: NAMESPACE
           valueFrom:
@@ -32,6 +37,9 @@ spec:
         image: {{ .Values.image.es_bb }}
         imagePullPolicy: {{ .Values.pullPolicy }}
         name: init-sysctl
+        volumeMounts:
+        - name: elasticsearch-logs
+          mountPath: /logroot/
       containers:
       - name: elasticsearch
         image: {{ .Values.image.elasticsearch}}
@@ -59,10 +67,10 @@ spec:
             claimName: elasticsearch-db
         - name: elasticsearch-logs
           hostPath:
-            path: /dockerdata-nfs/{{ .Values.nsPrefix }}/log/elasticsearch/logs
+            path: {{ .Values.dataRootDir }}/{{ .Values.nsPrefix }}/log/
         - name: elasticsearch-conf
           configMap:
-            name: elasticsearch-configmap
+            name: log-elasticsearch-configmap
             items:
             - key: elasticsearch.yml
               path: elasticsearch.yml
@@ -70,8 +78,8 @@ spec:
 apiVersion: v1
 kind: ConfigMap
 metadata:
-  name: elasticsearch-configmap
-  namespace: {{ .Values.nsPrefix }}-log
+  name: log-elasticsearch-configmap
+  namespace: {{ .Values.nsPrefix }}
 data:
 {{ (.Files.Glob "resources/elasticsearch/conf/elasticsearch.yml").AsConfig | indent 2 }}
 #{{ end }}