Merge "Elasticsearch: Add data node specific entrypoint override"
This commit is contained in:
commit
f353fc4ab9
@ -27,4 +27,48 @@ function stop () {
|
||||
kill -TERM 1
|
||||
}
|
||||
|
||||
function allocate_data_node () {
|
||||
CLUSTER_SETTINGS=$(curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \
|
||||
"${ELASTICSEARCH_ENDPOINT}/_cluster/settings")
|
||||
if echo "${CLUSTER_SETTINGS}" | grep -E "${NODE_NAME}"; then
|
||||
echo "Activate node ${NODE_NAME}"
|
||||
curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" -XPUT -H 'Content-Type: application/json' \
|
||||
"${ELASTICSEARCH_ENDPOINT}/_cluster/settings" -d "{
|
||||
\"transient\" :{
|
||||
\"cluster.routing.allocation.exclude._name\" : null
|
||||
}
|
||||
}"
|
||||
fi
|
||||
echo "Node ${NODE_NAME} is ready to be used"
|
||||
}
|
||||
|
||||
function start_data_node () {
|
||||
ulimit -l unlimited
|
||||
allocate_data_node &
|
||||
/docker-entrypoint.sh elasticsearch &
|
||||
function drain_data_node () {
|
||||
echo "Prepare to migrate data off node ${NODE_NAME}"
|
||||
echo "Move all data from node ${NODE_NAME}"
|
||||
curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" -XPUT -H 'Content-Type: application/json' \
|
||||
"${ELASTICSEARCH_ENDPOINT}/_cluster/settings" -d "{
|
||||
\"transient\" :{
|
||||
\"cluster.routing.allocation.exclude._name\" : \"${NODE_NAME}\"
|
||||
}
|
||||
}"
|
||||
echo ""
|
||||
while true ; do
|
||||
echo -e "Wait for node ${NODE_NAME} to become empty"
|
||||
SHARDS_ALLOCATION=$(curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \
|
||||
-XGET "${ELASTICSEARCH_ENDPOINT}/_cat/shards")
|
||||
if ! echo "${SHARDS_ALLOCATION}" | grep -E "${NODE_NAME}"; then
|
||||
break
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
echo "Node ${NODE_NAME} is ready to shutdown"
|
||||
}
|
||||
trap drain_data_node TERM EXIT HUP INT
|
||||
wait
|
||||
}
|
||||
|
||||
$COMMAND
|
||||
|
@ -17,6 +17,8 @@ limitations under the License.
|
||||
{{- if .Values.manifests.statefulset_data }}
|
||||
{{- $envAll := . }}
|
||||
|
||||
{{- $esUserSecret := .Values.secrets.elasticsearch.user }}
|
||||
|
||||
{{- $mounts_elasticsearch := .Values.pod.mounts.elasticsearch.elasticsearch }}
|
||||
|
||||
{{- $serviceAccountName := printf "%s-%s" .Release.Name "elasticsearch-data" }}
|
||||
@ -106,13 +108,7 @@ spec:
|
||||
{{ dict "envAll" $envAll "application" "data" "container" "elasticsearch_data" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
|
||||
command:
|
||||
- /tmp/elasticsearch.sh
|
||||
- start
|
||||
lifecycle:
|
||||
preStop:
|
||||
exec:
|
||||
command:
|
||||
- /tmp/elasticsearch.sh
|
||||
- stop
|
||||
- start_data_node
|
||||
ports:
|
||||
- name: transport
|
||||
containerPort: {{ tuple "elasticsearch" "internal" "discovery" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
|
||||
@ -130,6 +126,18 @@ spec:
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
- name: ELASTICSEARCH_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ $esUserSecret }}
|
||||
key: ELASTICSEARCH_USERNAME
|
||||
- name: ELASTICSEARCH_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ $esUserSecret }}
|
||||
key: ELASTICSEARCH_PASSWORD
|
||||
- name: ELASTICSEARCH_ENDPOINT
|
||||
value: {{ tuple "elasticsearch" "internal" "http" . | include "helm-toolkit.endpoints.host_and_port_endpoint_uri_lookup" }}
|
||||
- name: NODE_MASTER
|
||||
value: "false"
|
||||
- name: NODE_INGEST
|
||||
|
@ -223,7 +223,7 @@ pod:
|
||||
master:
|
||||
timeout: 600
|
||||
data:
|
||||
timeout: 600
|
||||
timeout: 1200
|
||||
client:
|
||||
timeout: 600
|
||||
prometheus_elasticsearch_exporter:
|
||||
|
Loading…
Reference in New Issue
Block a user