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 - name: elasticsearch-template-loader
image: docker.io/library/elasticsearch:8.5.1 image: docker.io/library/elasticsearch:8.5.1
command: command:
- /bin/bash - /bin/bash
- -c - -c
- | - |
set -ex set -ex
echo "[initContainer] Waiting for Elasticsearch at $ES_URL..." echo "[template-loader] Waiting for Elasticsearch at $ES_URL..."
for i in $(seq 1 ${MAX_RETRIES:-30}); do for i in $(seq 1 ${MAX_RETRIES:-30}); do
if curl -s "$ES_URL" >/dev/null; then if curl -s "$ES_URL" >/dev/null; then
echo "[initContainer] Elasticsearch is up!" echo "[template-loader] Elasticsearch is up!"
break break
fi fi
echo "[initContainer] Attempt $i: ES not ready, sleeping..." echo "[template-loader] Attempt $i: ES not ready, sleeping..."
sleep "${RETRY_INTERVAL:-5}" sleep "${RETRY_INTERVAL:-5}"
done done
echo "[template-loader] Applying templates..."
echo "[initContainer] Applying templates..." for idx in "chat:$TEMPLATE_PATH_1" "message:$TEMPLATE_PATH_2" "user:$TEMPLATE_PATH_3"; do
for idx in "chat:$TEMPLATE_PATH_1" "message:$TEMPLATE_PATH_2" "user:$TEMPLATE_PATH_3"; do name="${idx%%:*}"
name="${idx%%:*}" path="${idx##*:}"
path="${idx##*:}" echo "[template-loader] Applying $name from $path..."
echo "[initContainer] Applying $name from $path..." curl -X PUT "$ES_URL/$name" \
curl -X PUT "$ES_URL/$name" \ -H 'Content-Type: application/json' \
-H 'Content-Type: application/json' \ --data-binary @"$path"
--data-binary @"$path" done
done echo "[template-loader] All templates applied. Exiting."
echo "[initContainer] Done applying templates."
env: env:
- name: ES_URL - name: ES_URL
value: "http://elasticsearch-master:9200" value: "http://elasticsearch-master:9200"
@ -209,6 +208,10 @@ extraContainers:
value: "/templates/message.json" value: "/templates/message.json"
- name: TEMPLATE_PATH_3 - name: TEMPLATE_PATH_3
value: "/templates/user.json" value: "/templates/user.json"
- name: MAX_RETRIES
value: "30"
- name: RETRY_INTERVAL
value: "5"
volumeMounts: volumeMounts:
- name: index-template - name: index-template
mountPath: /templates mountPath: /templates