feat: readiness sentinel for Kubernetes

entrypoint.sh creates /home/agent/vol/.openclaw-initializing at startup
and removes it just before launching the gateway. Pod is not marked
ready until init (volume copy + config baking) is fully complete.

deployment.yaml adds readinessProbe: exec test ! -f sentinel,
with initialDelaySeconds=5, periodSeconds=5, failureThreshold=60
(5 minute window for slow storage on first deploy).
This commit is contained in:
Falkan
2026-03-26 22:29:47 -04:00
parent 1bdb48f04b
commit 7f32181ebe
2 changed files with 17 additions and 0 deletions

View File

@@ -64,6 +64,13 @@ spec:
- name: vol
mountPath: /home/agent/vol
readinessProbe:
exec:
command: ["test", "!", "-f", "/home/agent/vol/.openclaw-initializing"]
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 60
env:
# ── Required ────────────────────────────────────────────

View File

@@ -61,6 +61,14 @@ export OPENCLAW_GATEWAY_PORT="${OPENCLAW_GATEWAY_PORT:-18800}"
log() { echo "[entrypoint] $*"; }
warn() { echo "[entrypoint] WARNING: $*" >&2; }
# ── Readiness sentinel ────────────────────────────────────────────
# Present during init; deleted just before gateway starts.
# Kubernetes readiness probe: test ! -f /home/agent/vol/.openclaw-initializing
SENTINEL="${VOL}/.openclaw-initializing"
mkdir -p "${VOL}"
touch "${SENTINEL}"
log "Readiness sentinel created at ${SENTINEL}"
# ── Warn on missing required vars ────────────────────────────────
for var in OPENCLAW_GATEWAY_TOKEN OPENCLAW_DEFAULT_MODEL OPENCLAW_AGENT_NAME \
ANTHROPIC_API_KEY ANTHROPIC_MODEL ANTHROPIC_SMALL_FAST_MODEL PAI_AGENT_NAME; do
@@ -522,6 +530,8 @@ fi
# Run gateway in background. OpenClaw manages its own internal restarts.
# The sleep loop keeps the container alive if the gateway process exits.
log "Starting OpenClaw gateway on port ${OPENCLAW_GATEWAY_PORT}..."
rm -f "${SENTINEL}"
log "Readiness sentinel removed — pod is ready."
/home/agent/.npm-global/bin/openclaw gateway &
while true; do