1 ################################################################################
2 # Copyright (c) 2019 AT&T Intellectual Property. #
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 #
8 # http://www.apache.org/licenses/LICENSE-2.0 #
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 ################################################################################
21 name: {{ template "uname" . }}
23 heritage: {{ .Release.Service | quote }}
24 release: {{ .Release.Name | quote }}
25 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
26 app: "{{ template "uname" . }}"
27 {{- range $key, $value := .Values.labels }}
28 {{ $key }}: {{ $value | quote }}
31 esMajorVersion: "{{ include "esMajorVersion" . }}"
33 serviceName: {{ template "uname" . }}-headless
36 app: "{{ template "uname" . }}"
37 replicas: {{ default .Values.replicas }}
38 podManagementPolicy: {{ .Values.podManagementPolicy }}
40 type: {{ .Values.updateStrategy }}
41 {{- if .Values.persistence.enabled }}
44 name: {{ template "uname" . }}
45 {{- with .Values.persistence.annotations }}
47 {{ toYaml . | indent 8 }}
50 {{ toYaml .Values.volumeClaimTemplate | indent 6 }}
54 name: "{{ template "uname" . }}"
56 heritage: {{ .Release.Service | quote }}
57 release: {{ .Release.Name | quote }}
58 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
59 app: "{{ template "uname" . }}"
61 {{- range $key, $value := .Values.podAnnotations }}
62 {{ $key }}: {{ $value | quote }}
64 {{/* This forces a restart if the configmap has changed */}}
65 {{- if .Values.esConfig }}
66 configchecksum: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum | trunc 63 }}
69 {{- if .Values.schedulerName }}
70 schedulerName: "{{ .Values.schedulerName }}"
73 {{ toYaml .Values.podSecurityContext | indent 8 }}
74 {{- if .Values.fsGroup }}
75 fsGroup: {{ .Values.fsGroup }} # Deprecated value, please use .Values.podSecurityContext.fsGroup
77 {{- with .Values.tolerations }}
79 {{ toYaml . | indent 6 }}
81 {{- with .Values.nodeSelector }}
83 {{ toYaml . | indent 8 }}
85 {{- if or (eq .Values.antiAffinity "hard") (eq .Values.antiAffinity "soft") .Values.nodeAffinity }}
86 {{- if .Values.priorityClassName }}
87 priorityClassName: {{ .Values.priorityClassName }}
91 {{- if eq .Values.antiAffinity "hard" }}
93 requiredDuringSchedulingIgnoredDuringExecution:
99 - "{{ template "uname" .}}"
100 topologyKey: {{ .Values.antiAffinityTopologyKey }}
101 {{- else if eq .Values.antiAffinity "soft" }}
103 preferredDuringSchedulingIgnoredDuringExecution:
106 topologyKey: {{ .Values.antiAffinityTopologyKey }}
112 - "{{ template "uname" . }}"
114 {{- with .Values.nodeAffinity }}
116 {{ toYaml . | indent 10 }}
118 terminationGracePeriodSeconds: {{ .Values.terminationGracePeriod }}
120 {{- range .Values.secretMounts }}
123 secretName: {{ .secretName }}
125 {{- if .Values.esConfig }}
128 name: {{ template "uname" . }}-config
130 {{- if .Values.extraVolumes }}
131 {{ tpl .Values.extraVolumes . | indent 6 }}
133 {{- if .Values.imagePullSecrets }}
135 {{ toYaml .Values.imagePullSecrets | indent 8 }}
138 {{- if .Values.sysctlInitContainer.enabled }}
139 - name: configure-sysctl
143 image: "{{ .Values.image }}:{{ .Values.imageTag }}"
144 command: ["sysctl", "-w", "vm.max_map_count={{ .Values.sysctlVmMaxMapCount}}"]
146 {{ toYaml .Values.initResources | indent 10 }}
148 {{- if .Values.extraInitContainers }}
149 {{ tpl .Values.extraInitContainers . | indent 6 }}
152 - name: "{{ template "name" . }}"
154 {{ toYaml .Values.securityContext | indent 10 }}
155 image: "{{ .Values.image }}:{{ .Values.imageTag }}"
156 imagePullPolicy: "{{ .Values.imagePullPolicy }}"
158 {{ toYaml .Values.readinessProbe | indent 10 }}
164 #!/usr/bin/env bash -e
165 # If the node is starting up wait for the cluster to be ready (request params: '{{ .Values.clusterHealthCheckParams }}' )
166 # Once it has started only check that the node itself is responding
167 START_FILE=/tmp/.es_start_file
171 if [ -n "${ELASTIC_USERNAME}" ] && [ -n "${ELASTIC_PASSWORD}" ]; then
172 BASIC_AUTH="-u ${ELASTIC_USERNAME}:${ELASTIC_PASSWORD}"
176 curl -XGET -s -k --fail ${BASIC_AUTH} {{ .Values.protocol }}://127.0.0.1:{{ .Values.httpPort }}${path}
179 if [ -f "${START_FILE}" ]; then
180 echo 'Elasticsearch is already running, lets check the node is healthy'
183 echo 'Waiting for elasticsearch cluster to become cluster to be ready (request params: "{{ .Values.clusterHealthCheckParams }}" )'
184 if http "/_cluster/health?{{ .Values.clusterHealthCheckParams }}" ; then
188 echo 'Cluster is not yet ready (request params: "{{ .Values.clusterHealthCheckParams }}" )'
194 containerPort: {{ .Values.httpPort }}
196 containerPort: {{ .Values.transportPort }}
198 {{ toYaml .Values.resources | indent 10 }}
203 fieldPath: metadata.name
204 {{- if eq .Values.roles.master "true" }}
205 {{- if ge (int (include "esMajorVersion" .)) 7 }}
206 - name: cluster.initial_master_nodes
207 value: "{{ template "endpoints" .Values }}"
209 - name: discovery.zen.minimum_master_nodes
210 value: "{{ .Values.minimumMasterNodes }}"
213 {{- if lt (int (include "esMajorVersion" .)) 7 }}
214 - name: discovery.zen.ping.unicast.hosts
215 value: "{{ template "masterService" . }}-headless"
217 - name: discovery.seed_hosts
218 value: "{{ template "masterService" . }}-headless"
221 value: "{{ .Values.clusterName }}"
223 value: "{{ .Values.networkHost }}"
225 value: "{{ .Values.esJavaOpts }}"
226 {{- range $role, $enabled := .Values.roles }}
227 - name: node.{{ $role }}
228 value: "{{ $enabled }}"
230 {{- if .Values.extraEnvs }}
231 {{ toYaml .Values.extraEnvs | indent 10 }}
234 {{- if .Values.persistence.enabled }}
235 - name: "{{ template "uname" . }}"
236 mountPath: /usr/share/elasticsearch/data
238 {{- range .Values.secretMounts }}
240 mountPath: {{ .path }}
242 subPath: {{ .subPath }}
245 {{- range $path, $config := .Values.esConfig }}
247 mountPath: /usr/share/elasticsearch/config/{{ $path }}
250 {{- if .Values.extraVolumeMounts }}
251 {{ tpl .Values.extraVolumeMounts . | indent 10 }}
253 {{- if .Values.masterTerminationFix }}
254 {{- if eq .Values.roles.master "true" }}
255 # This sidecar will prevent slow master re-election
256 # https://github.com/elastic/helm-charts/issues/63
257 - name: elasticsearch-master-graceful-termination-handler
258 image: "{{ .Values.image }}:{{ .Values.imageTag }}"
259 imagePullPolicy: "{{ .Values.imagePullPolicy }}"
269 if [ -n "${ELASTIC_USERNAME}" ] && [ -n "${ELASTIC_PASSWORD}" ]; then
270 BASIC_AUTH="-u ${ELASTIC_USERNAME}:${ELASTIC_PASSWORD}"
274 curl -XGET -s -k --fail ${BASIC_AUTH} {{ .Values.protocol }}://{{ template "masterService" . }}:{{ .Values.httpPort }}${path}
279 local master="$(http "/_cat/master?h=node" || echo "")"
280 if [[ $master == "{{ template "masterService" . }}"* && $master != "${NODE_NAME}" ]]; then
281 echo "This node is not master."
284 echo "This node is still master, waiting gracefully for it to step down"
296 {{ toYaml .Values.sidecarResources | indent 10 }}
301 fieldPath: metadata.name
302 {{- if .Values.extraEnvs }}
303 {{ toYaml .Values.extraEnvs | indent 10 }}
307 {{- if .Values.lifecycle }}
309 {{ toYaml .Values.lifecycle | indent 10 }}