Replica Scaling of Consul and Log container
[oom.git] / kubernetes / log / templates / elasticsearch-deployment.yaml
1 #{{ if not .Values.disableLogElasticsearch }}
2 apiVersion: extensions/v1beta1
3 kind: Deployment
4 metadata:
5   labels:
6     app: elasticsearch
7   name: log-elasticsearch
8   namespace: {{ .Values.nsPrefix }}
9 spec:
10   replicas: {{ .Values.elasticsearchReplicas }}
11   selector:
12     matchLabels:
13       app: elasticsearch
14   template:
15     metadata:
16       labels:
17         app: elasticsearch
18       name: log-elasticsearch
19     spec:
20       initContainers:
21       - command:
22         - /bin/sh
23         - -c
24         - |
25           sysctl -w vm.max_map_count=262144
26           mkdir -p /logroot/elasticsearch/logs
27           mkdir -p /logroot/elasticsearch/data
28           chmod -R 777 /logroot/elasticsearch
29           chown -R root:root /logroot
30         env:
31         - name: NAMESPACE
32           valueFrom:
33             fieldRef:
34               apiVersion: v1
35               fieldPath: metadata.namespace
36         securityContext:
37           privileged: true
38         image: {{ .Values.image.es_bb }}
39         imagePullPolicy: {{ .Values.pullPolicy }}
40         name: init-sysctl
41         volumeMounts:
42         - name: elasticsearch-logs
43           mountPath: /logroot/
44       containers:
45       - name: elasticsearch
46         image: {{ .Values.image.elasticsearch}}
47         ports:
48         - containerPort: 9200
49           name: http
50           protocol: TCP
51         - containerPort: 9300
52           name: transport
53           protocol: TCP
54         readinessProbe:
55           tcpSocket:
56             port: 9300
57         volumeMounts:
58          - mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
59            name: elasticsearch-conf
60            subPath: elasticsearch.yml
61          - mountPath: /usr/share/elasticsearch/data/
62            name: elasticsearch-data
63          - mountPath: /usr/share/elasticsearch/logs/
64            name: elasticsearch-logs
65       volumes:
66         - name: elasticsearch-data
67           persistentVolumeClaim:
68             claimName: elasticsearch-db
69         - name: elasticsearch-logs
70           hostPath:
71             path: {{ .Values.dataRootDir }}/{{ .Values.nsPrefix }}/log/
72         - name: elasticsearch-conf
73           configMap:
74             name: log-elasticsearch-configmap
75             items:
76             - key: elasticsearch.yml
77               path: elasticsearch.yml
78 ---
79 apiVersion: v1
80 kind: ConfigMap
81 metadata:
82   name: log-elasticsearch-configmap
83   namespace: {{ .Values.nsPrefix }}
84 data:
85 {{ (.Files.Glob "resources/elasticsearch/conf/elasticsearch.yml").AsConfig | indent 2 }}
86 #{{ end }}
87