Skip to content

Commit

Permalink
rewrite without voting_config_exclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
kimxogus committed May 2, 2019
1 parent 8d6aa26 commit 631ce4c
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions elasticsearch/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,50 @@ spec:
{{- if .Values.extraVolumeMounts }}
{{ tpl .Values.extraVolumeMounts . | indent 10 }}
{{- end }}
{{- if eq .Values.roles.master "true" }}
- name: graceful-termination-handler
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
imagePullPolicy: "{{ .Values.imagePullPolicy }}"
command:
- "sh"
- -c
- |
#!/usr/bin/env bash
set -eo pipefail
http () {
local path="${1}"
if [ -n "${ELASTIC_USERNAME}" ] && [ -n "${ELASTIC_PASSWORD}" ]; then
BASIC_AUTH="-u ${ELASTIC_USERNAME}:${ELASTIC_PASSWORD}"
else
BASIC_AUTH=''
fi
curl -XGET -s -k --fail ${BASIC_AUTH} {{ .Values.protocol }}://{{ template "masterService" . }}:{{ .Values.httpPort }}${path}
}
cleanup () {
while true ; do
local master="$(http "/_cat/master")"
if [[ $master == *"{{ template "uname" . }}"* && $master != *"${NODE_NAME}"* ]]; then
echo "This node is not master."
break
fi
echo "This node is still master, waiting gracefully for it to step down"
sleep 1
done
exit 0
}
trap cleanup SIGTERM
while true; do
sleep 60 &
wait $!
done
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
{{- end }}

0 comments on commit 631ce4c

Please # to comment.