File tree 1 file changed +49
-0
lines changed
1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -216,3 +216,52 @@ spec:
216
216
{{- if .Values.extraVolumeMounts }}
217
217
{{ tpl .Values.extraVolumeMounts . | indent 10 }}
218
218
{{- end }}
219
+ {{- if eq .Values.roles.master "true" }}
220
+ - name : graceful-termination-handler
221
+ image : " {{ .Values.image }}:{{ .Values.imageTag }}"
222
+ imagePullPolicy : " {{ .Values.imagePullPolicy }}"
223
+ command :
224
+ - " sh"
225
+ - -c
226
+ - |
227
+ #!/usr/bin/env bash
228
+ set -eo pipefail
229
+
230
+ http () {
231
+ local path="${1}"
232
+ if [ -n "${ELASTIC_USERNAME}" ] && [ -n "${ELASTIC_PASSWORD}" ]; then
233
+ BASIC_AUTH="-u ${ELASTIC_USERNAME}:${ELASTIC_PASSWORD}"
234
+ else
235
+ BASIC_AUTH=''
236
+ fi
237
+ curl -XGET -s -k --fail ${BASIC_AUTH} {{ .Values.protocol }}://${MASTER_SERVICE}:{{ .Values.httpPort }}${path}
238
+ }
239
+
240
+ cleanup () {
241
+ while true ; do
242
+ local master="$(http "/_cat/master")"
243
+ if [[ $master == *"{{ template "uname" . }}"* && $master != *"${NODE_NAME}"* ]]; then
244
+ echo "This node is not master."
245
+ break
246
+ fi
247
+ echo "This node is still master, waiting gracefully for it to step down"
248
+ sleep 1
249
+ done
250
+
251
+ exit 0
252
+ }
253
+
254
+ trap cleanup SIGTERM
255
+
256
+ while true; do
257
+ sleep 60 &
258
+ wait $!
259
+ done
260
+ env :
261
+ - name : NODE_NAME
262
+ valueFrom :
263
+ fieldRef :
264
+ fieldPath : metadata.name
265
+ - name : MASTER_SERVICE
266
+ value : " {{ template " masterService" . }}-headless"
267
+ {{- end }}
You can’t perform that action at this time.
0 commit comments