From 1f98bd221eea4d99fa3a2ee23d0688051f3ef2cf Mon Sep 17 00:00:00 2001 From: Leo Sok Date: Thu, 24 Jul 2025 12:49:46 +0300 Subject: [PATCH] poststartup script moved to extra container, non init --- elasticsearch/values.yaml | 51 +++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/elasticsearch/values.yaml b/elasticsearch/values.yaml index 6940def..40bb970 100644 --- a/elasticsearch/values.yaml +++ b/elasticsearch/values.yaml @@ -176,30 +176,29 @@ extraContainers: - name: elasticsearch-template-loader image: docker.io/library/elasticsearch:8.5.1 command: - - /bin/bash - - -c - - | - set -ex - echo "[initContainer] Waiting for Elasticsearch at $ES_URL..." - for i in $(seq 1 ${MAX_RETRIES:-30}); do - if curl -s "$ES_URL" >/dev/null; then - echo "[initContainer] Elasticsearch is up!" - break - fi - echo "[initContainer] Attempt $i: ES not ready, sleeping..." - sleep "${RETRY_INTERVAL:-5}" - done - - echo "[initContainer] Applying templates..." - for idx in "chat:$TEMPLATE_PATH_1" "message:$TEMPLATE_PATH_2" "user:$TEMPLATE_PATH_3"; do - name="${idx%%:*}" - path="${idx##*:}" - echo "[initContainer] Applying $name from $path..." - curl -X PUT "$ES_URL/$name" \ - -H 'Content-Type: application/json' \ - --data-binary @"$path" - done - echo "[initContainer] Done applying templates." + - /bin/bash + - -c + - | + set -ex + echo "[template-loader] Waiting for Elasticsearch at $ES_URL..." + for i in $(seq 1 ${MAX_RETRIES:-30}); do + if curl -s "$ES_URL" >/dev/null; then + echo "[template-loader] Elasticsearch is up!" + break + fi + echo "[template-loader] Attempt $i: ES not ready, sleeping..." + sleep "${RETRY_INTERVAL:-5}" + done + echo "[template-loader] Applying templates..." + for idx in "chat:$TEMPLATE_PATH_1" "message:$TEMPLATE_PATH_2" "user:$TEMPLATE_PATH_3"; do + name="${idx%%:*}" + path="${idx##*:}" + echo "[template-loader] Applying $name from $path..." + curl -X PUT "$ES_URL/$name" \ + -H 'Content-Type: application/json' \ + --data-binary @"$path" + done + echo "[template-loader] All templates applied. Exiting." env: - name: ES_URL value: "http://elasticsearch-master:9200" @@ -209,6 +208,10 @@ extraContainers: value: "/templates/message.json" - name: TEMPLATE_PATH_3 value: "/templates/user.json" + - name: MAX_RETRIES + value: "30" + - name: RETRY_INTERVAL + value: "5" volumeMounts: - name: index-template mountPath: /templates