From d6a246a2d188a14581bf7c8d8d6532eee26846de Mon Sep 17 00:00:00 2001 From: Leo Sok Date: Mon, 16 Jun 2025 17:21:22 +0300 Subject: [PATCH] elastic https disabled --- elasticsearch/templates/statefulset.yaml | 47 ++++++------------------ elasticsearch/values.yaml | 2 +- 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/elasticsearch/templates/statefulset.yaml b/elasticsearch/templates/statefulset.yaml index 64fd423..8d06221 100644 --- a/elasticsearch/templates/statefulset.yaml +++ b/elasticsearch/templates/statefulset.yaml @@ -237,66 +237,43 @@ spec: exec: command: - bash - - -c - - | + - '-c' + - > set -e - # 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 }}" ) + # If the node is starting up wait for the cluster to be ready # Once it has started only check that the node itself is responding START_FILE=/tmp/.es_start_file - # Disable nss cache to avoid filling dentry cache when calling curl - # This is required with Elasticsearch Docker using nss < 3.52 + # Disable nss cache (kept for compatibility) export NSS_SDB_USE_CACHE=no http () { local path="${1}" local args="${2}" - 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}" + curl -XGET -s --output /dev/null -w "%{http_code}" "http://127.0.0.1:9200${path}" ${args} } if [ -f "${START_FILE}" ]; then - echo 'Elasticsearch is already running, lets check the node is healthy' - 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 + echo 'Elasticsearch is already running, checking node health' + HTTP_CODE=$(http "/") if [[ ${HTTP_CODE} == "200" ]]; then exit 0 - elif [[ ${HTTP_CODE} == "503" && "{{ include "elasticsearch.esMajorVersion" . }}" == "6" ]]; then - exit 0 else - 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}" + echo "Health check failed with HTTP code ${HTTP_CODE}" exit 1 fi - else - echo 'Waiting for elasticsearch cluster to become ready (request params: "{{ .Values.clusterHealthCheckParams }}" )' - if http "/_cluster/health?{{ .Values.clusterHealthCheckParams }}" "--fail" ; then + echo 'Waiting for elasticsearch cluster to become ready' + if http "/_cluster/health?wait_for_status=green&timeout=1s" "--fail"; then touch ${START_FILE} exit 0 else - echo 'Cluster is not yet ready (request params: "{{ .Values.clusterHealthCheckParams }}" )' + echo 'Cluster is not yet ready' exit 1 fi fi + {{ toYaml .Values.readinessProbe | indent 10 }} ports: - name: http diff --git a/elasticsearch/values.yaml b/elasticsearch/values.yaml index 5aa8322..b447062 100644 --- a/elasticsearch/values.yaml +++ b/elasticsearch/values.yaml @@ -264,7 +264,7 @@ readinessProbe: timeoutSeconds: 5 # https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html#request-params wait_for_status -clusterHealthCheckParams: "wait_for_status=green&timeout=1s" +clusterHealthCheckParams: "wait_for_status=green&timeout=15s" ## Use an alternate scheduler. ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/