poststartup script moved to extra container, non init

This commit is contained in:
Leo Sok 2025-07-24 12:49:46 +03:00
parent 518c6632bf
commit 1f98bd221e

View File

@ -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