
Kubernetes initiates "graceful shutdown" by sending SIGTERM to pid 1. The way the existing startup scripts worked, this signal arrived at the shell wrapper, not elasticsearch, and the shell wrapper exited, killing the container immediately. Before this change: 1 ? Ss 0:00 /bin/sh -c /run.sh 6 ? S 0:00 /bin/bash /run.sh 13 ? S 0:00 \_ /bin/su -c /elasticsearch/bin/elasticsearch elasticsearch 14 ? Ss 0:00 \_ sh -c /elasticsearch/bin/elasticsearch 15 ? Sl 19:18 \_ /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java ... org.elasticsearch.bootstrap.Elasticsearch start After this change: 1 ? Ssl 0:29 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java ... org.elasticsearch.bootstrap.Elasticsearch start
29 lines
1.0 KiB
Bash
Executable File
29 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Copyright 2015 The Kubernetes Authors.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
export NODE_NAME=${NODE_NAME:-${HOSTNAME}}
|
|
export NODE_MASTER=${NODE_MASTER:-true}
|
|
export NODE_DATA=${NODE_DATA:-true}
|
|
export HTTP_PORT=${HTTP_PORT:-9200}
|
|
export TRANSPORT_PORT=${TRANSPORT_PORT:-9300}
|
|
export MINIMUM_MASTER_NODES=${MINIMUM_MASTER_NODES:-2}
|
|
|
|
/elasticsearch_logging_discovery >> /elasticsearch/config/elasticsearch.yml
|
|
|
|
chown -R elasticsearch:elasticsearch /data
|
|
|
|
exec gosu elasticsearch /elasticsearch/bin/elasticsearch
|