elastic https disabled
This commit is contained in:
parent
6af4302a10
commit
4968def2df
@ -237,43 +237,66 @@ spec:
|
|||||||
exec:
|
exec:
|
||||||
command:
|
command:
|
||||||
- bash
|
- bash
|
||||||
- '-c'
|
- -c
|
||||||
- >
|
- |
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# If the node is starting up wait for the cluster to be ready
|
# Exit if ELASTIC_PASSWORD in unset
|
||||||
|
if [ -z "${ELASTIC_PASSWORD}" ]; then
|
||||||
|
echo "ELASTIC_PASSWORD variable is missing, exiting"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the node is starting up wait for the cluster to be ready (request params: "{{ .Values.clusterHealthCheckParams }}" )
|
||||||
# Once it has started only check that the node itself is responding
|
# Once it has started only check that the node itself is responding
|
||||||
START_FILE=/tmp/.es_start_file
|
START_FILE=/tmp/.es_start_file
|
||||||
|
|
||||||
# Disable nss cache (kept for compatibility)
|
# Disable nss cache to avoid filling dentry cache when calling curl
|
||||||
|
# This is required with Elasticsearch Docker using nss < 3.52
|
||||||
export NSS_SDB_USE_CACHE=no
|
export NSS_SDB_USE_CACHE=no
|
||||||
|
|
||||||
http () {
|
http () {
|
||||||
local path="${1}"
|
local path="${1}"
|
||||||
local args="${2}"
|
local args="${2}"
|
||||||
curl -XGET -s --output /dev/null -w "%{http_code}" "http://127.0.0.1:9200${path}" ${args}
|
set -- -XGET -s
|
||||||
|
|
||||||
|
if [ "$args" != "" ]; then
|
||||||
|
set -- "$@" $args
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -- "$@" -u "elastic:${ELASTIC_PASSWORD}"
|
||||||
|
|
||||||
|
curl --output /dev/null -k "$@" "{{ .Values.protocol }}://127.0.0.1:{{ .Values.httpPort }}${path}"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -f "${START_FILE}" ]; then
|
if [ -f "${START_FILE}" ]; then
|
||||||
echo 'Elasticsearch is already running, checking node health'
|
echo 'Elasticsearch is already running, lets check the node is healthy'
|
||||||
HTTP_CODE=$(http "/")
|
HTTP_CODE=$(http "/" "-w %{http_code}")
|
||||||
|
RC=$?
|
||||||
|
if [[ ${RC} -ne 0 ]]; then
|
||||||
|
echo "curl --output /dev/null -k -XGET -s -w '%{http_code}' \${BASIC_AUTH} {{ .Values.protocol }}://127.0.0.1:{{ .Values.httpPort }}/ failed with RC ${RC}"
|
||||||
|
exit ${RC}
|
||||||
|
fi
|
||||||
|
# ready if HTTP code 200, 503 is tolerable if ES version is 6.x
|
||||||
if [[ ${HTTP_CODE} == "200" ]]; then
|
if [[ ${HTTP_CODE} == "200" ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
|
elif [[ ${HTTP_CODE} == "503" && "{{ include "elasticsearch.esMajorVersion" . }}" == "6" ]]; then
|
||||||
|
exit 0
|
||||||
else
|
else
|
||||||
echo "Health check failed with HTTP code ${HTTP_CODE}"
|
echo "curl --output /dev/null -k -XGET -s -w '%{http_code}' \${BASIC_AUTH} {{ .Values.protocol }}://127.0.0.1:{{ .Values.httpPort }}/ failed with HTTP code ${HTTP_CODE}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
echo 'Waiting for elasticsearch cluster to become ready'
|
echo 'Waiting for elasticsearch cluster to become ready (request params: "{{ .Values.clusterHealthCheckParams }}" )'
|
||||||
if http "/_cluster/health?wait_for_status=green&timeout=1s" "--fail"; then
|
if http "/_cluster/health?{{ .Values.clusterHealthCheckParams }}" "--fail" ; then
|
||||||
touch ${START_FILE}
|
touch ${START_FILE}
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
echo 'Cluster is not yet ready'
|
echo 'Cluster is not yet ready (request params: "{{ .Values.clusterHealthCheckParams }}" )'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
{{ toYaml .Values.readinessProbe | indent 10 }}
|
{{ toYaml .Values.readinessProbe | indent 10 }}
|
||||||
ports:
|
ports:
|
||||||
- name: http
|
- name: http
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user