[SO] 16.0.4 release
[oom.git] / kubernetes / common / elasticsearch / components / master / templates / statefulset.yaml
1 {{/*
2 # Copyright © 2020 Bitnami, AT&T, Amdocs, Bell Canada, highstreet technologies
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 */}}
16
17 apiVersion: apps/v1
18 kind: StatefulSet
19 {{ $role := "master" -}}
20 {{ $suffix := $role -}}
21 {{ $labels := (dict "role" $role "discovery" .Values.cluster_name) -}}
22 metadata: {{- include "common.resourceMetadata" (dict "suffix" $suffix "labels" $labels "dot" . )| nindent 2 }}
23 spec:
24   updateStrategy:
25     type: {{ .Values.updateStrategy.type }}
26     {{- if (eq "OnDelete" .Values.updateStrategy.type) }}
27     rollingUpdate: null
28     {{- end }}
29   selector: {{- include "common.selectors" (dict "matchLabels" $labels "dot" .)| nindent 4 }}
30   serviceName: {{ include "common.fullname" . }}-master
31   replicas: {{ .Values.replicaCount }}
32   template:
33     metadata: {{- include "common.templateMetadata" (dict "labels" $labels "dot" .) | nindent 6 }}
34     spec:
35       {{- include "common.imagePullSecrets" . | nindent 6 }}
36       {{- if .Values.affinity }}
37       affinity: {{- include "common.tplValue" (dict "value" .Values.affinity "context" $) | nindent 8 }}
38       {{- end }}
39       {{- if .Values.nodeSelector }}
40       nodeSelector: {{- include "common.tplValue" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
41       {{- end }}
42       {{- if .Values.tolerations }}
43       tolerations: {{- include "common.tplValue" (dict "value" .Values.tolerations "context" $) | nindent 8 }}
44       {{- end }}
45       {{ include "common.podSecurityContext" . | indent 6 | trim }}
46       initContainers:
47         {{- if .Values.sysctlImage.enabled }}
48         ## Image that performs the sysctl operation to modify Kernel settings (needed sometimes to avoid boot errors)
49         - name: sysctl
50           image: {{ include "repositoryGenerator.image.busybox" . }}
51           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
52           {{ include "common.containerSecurityContext" . | indent 10 | trim }}
53           resources:
54             limits:
55               cpu: 20m
56               memory: 50Mi
57             requests:
58               cpu: 5m
59               memory: 20Mi
60           command:
61             - /bin/sh
62             - -c
63             - |
64               set -o errexit
65               set -o pipefail
66               set -o nounset
67           volumeMounts:
68             - mountPath: /etc/sysctl.conf
69               name: config
70               subPath: sysctl.conf
71         {{- end }}
72         - name: {{ include "common.name" . }}-config-copy
73           image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }}
74           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
75           {{ include "common.containerSecurityContext" . | indent 10 | trim }}
76           resources:
77             limits:
78               cpu: 20m
79               memory: 50Mi
80             requests:
81               cpu: 5m
82               memory: 20Mi
83           command:
84             - /bin/sh
85             - -c
86             - |
87               cp -R /opt/bitnami/elasticsearch/config/. /opt/bitnami/elasticsearch/config_rw
88           volumeMounts:
89             - mountPath: /opt/bitnami/elasticsearch/config_rw
90               name: bitnami-config
91       containers:
92         - name: {{ include "common.name" . }}-master
93           image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }}
94           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
95           {{ include "common.containerSecurityContext" . | indent 10 | trim }}
96           env:
97             - name: BITNAMI_DEBUG
98               value: {{ ternary "true" "false" .Values.debug | quote }}
99             - name: ELASTICSEARCH_CLUSTER_NAME
100               value: {{ .Values.cluster_name }}
101             - name: ELASTICSEARCH_CLUSTER_HOSTS
102               value: {{ include "common.name" . }}-discovery
103             - name: ELASTICSEARCH_CLUSTER_MASTER_HOSTS
104               {{- $elasticsearchMasterFullname := printf "%s-%s" (include "common.fullname" . ) "master" }}
105               {{- $replicas := int .Values.replicaCount }}
106               value: {{range $i, $e := until $replicas }}{{ $elasticsearchMasterFullname }}-{{ $e }} {{ end }}
107             - name: ELASTICSEARCH_MINIMUM_MASTER_NODES
108               value: {{ add (div .Values.replicaCount 2) 1 | quote }}
109             {{- if .Values.plugins }}
110             - name: ELASTICSEARCH_PLUGINS
111               value: {{ .Values.plugins | quote }}
112             {{- end }}
113             - name: ELASTICSEARCH_HEAP_SIZE
114               value: {{ .Values.heapSize | quote }}
115             - name: ELASTICSEARCH_IS_DEDICATED_NODE
116               value: {{ .Values.dedicatednode | quote }}
117             - name: ELASTICSEARCH_NODE_TYPE
118               value: "master"
119             - name: network.bind_host
120               value: 127.0.0.1
121             - name: network.publish_host
122               valueFrom:
123                 fieldRef:
124                   fieldPath: status.podIP
125           ports: {{- include "common.containerPorts" . |indent 12 }}
126           {{- if .Values.livenessProbe.enabled }}
127           livenessProbe:
128             initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
129             periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
130             timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
131             successThreshold: {{ .Values.livenessProbe.successThreshold }}
132             failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
133             httpGet:
134               path: /_cluster/health?local=true
135               port: 9200
136           {{- end }}
137           {{- if .Values.readinessProbe.enabled }}
138           readinessProbe:
139             initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
140             periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
141             timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
142             successThreshold: {{ .Values.livenessProbe.successThreshold }}
143             failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
144             httpGet:
145               path: /_cluster/health?local=true
146               port: 9200
147           {{- end }}
148           {{- if .Values.resources }}
149           resources: {{- toYaml .Values.resources | nindent 12 }}
150           {{- end }}
151           volumeMounts:
152             - mountPath: /tmp
153               name: tmp
154             - mountPath: /opt/bitnami/elasticsearch/logs
155               name: bitnami-logs
156             - mountPath: /opt/bitnami/elasticsearch/tmp
157               name: bitnami-tmp
158             - mountPath: /opt/bitnami/elasticsearch/config
159               name: bitnami-config
160             {{- if .Values.config }}
161             - mountPath: /opt/bitnami/elasticsearch/config/elasticsearch.yml
162               name: config
163               subPath: elasticsearch.yml
164             {{- end }}
165             - name: data
166               mountPath: /bitnami/elasticsearch/data
167             {{- if .Values.extraVolumeMounts }}
168             {{- toYaml .Values.extraVolumeMounts | nindent 12 }}
169             {{- end }}
170       volumes:
171         - name: config
172           configMap:
173             name: {{ include "common.fullname" . }}
174         - emptyDir:
175             sizeLimit: {{ .Values.volumes.tmpSizeLimit }}
176           name: tmp
177         - emptyDir:
178             sizeLimit: {{ .Values.volumes.bitnamiLogsSizeLimit }}
179           name: bitnami-logs
180         - emptyDir:
181             sizeLimit: {{ .Values.volumes.bitnamiTmpSizeLimit }}
182           name: bitnami-tmp
183         - emptyDir:
184             sizeLimit: {{ .Values.volumes.bitnamiConfigSizeLimit }}
185           name: bitnami-config
186         {{- if .Values.extraVolumes }}
187         {{- toYaml .Values.extraVolumes | nindent 8 }}
188         {{- end }}
189 {{- if not .Values.persistence.enabled }}
190         - name: "data"
191           emptyDir:
192             sizeLimit: {{ .Values.volumes.dataSizeLimit }}
193 {{- else }}
194   volumeClaimTemplates:
195     - metadata:
196         name: "data"
197         {{- if .Values.persistence.annotations }}
198         annotations: {{- toYaml .Values.persistence.annotations | nindent 10 }}
199         {{- end }}
200       spec:
201         accessModes:
202           - {{ .Values.persistence.accessMode }}
203         storageClassName: {{ include "common.storageClass" (dict "dot" . "suffix" .Values.persistence.suffix) }}
204         resources:
205           requests:
206             storage: {{ .Values.persistence.size | quote }}
207 {{- end }}