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 e29d2db
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions elasticsearch/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,52 @@ 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 }}://${MASTER_SERVICE}:{{ .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
- name: MASTER_SERVICE
value: "{{ template "masterService" . }}-headless"
{{- end }}

0 comments on commit e29d2db

Please sign in to comment.