Non-blocking entrypoint + k3s --flannel-iface fix #46

Merged
will.anderson merged 2 commits from dev into stage 2026-05-10 17:55:17 +00:00
+13 -15
View File
@@ -16,28 +16,26 @@ echo "[entrypoint] Starting k3s server (embedded soul-demo orchestrator)..."
# --disable metrics-server: saves ~50MB RAM # --disable metrics-server: saves ~50MB RAM
# --write-kubeconfig-mode=644: allow non-root reads # --write-kubeconfig-mode=644: allow non-root reads
# --data-dir: use the pre-chowned dir # --data-dir: use the pre-chowned dir
# --flannel-iface=eth0: explicitly set the network interface.
# Cloud Run gen2 provides eth0 but k3s default IP detection walks the routing
# table looking for a default route, which fails in Cloud Run's network sandbox.
# Pinning to eth0 bypasses that detection and lets k3s bind correctly.
k3s server \ k3s server \
--disable traefik \ --disable traefik \
--disable servicelb \ --disable servicelb \
--disable metrics-server \ --disable metrics-server \
--write-kubeconfig-mode=644 \ --write-kubeconfig-mode=644 \
--data-dir /var/lib/rancher/k3s \ --data-dir /var/lib/rancher/k3s \
--node-name soul-node & --node-name soul-node \
--flannel-iface=eth0 &
K3S_PID=$! K3S_PID=$!
echo "[entrypoint] Waiting for k3s to become ready..." # Start neuron-web immediately — do NOT block on k3s becoming ready.
until k3s kubectl get nodes --no-headers 2>/dev/null | grep -q "Ready"; do # Cloud Run's startup probe requires port 8080 to be listening within the
sleep 2 # startup timeout. k3s may take 30-60s to initialise; blocking here causes
done # probe failures and container termination before neuron-web ever starts.
echo "[entrypoint] k3s ready. soul-demo Deployment will be applied automatically from manifests." # soul-demo becomes available asynchronously once k3s is ready. neuron-web
# handles soul-demo being temporarily unavailable gracefully.
# Wait for soul-demo pod to be Running before starting neuron-web echo "[entrypoint] Starting neuron-web on port ${PORT:-8080} (k3s initialising in background)..."
echo "[entrypoint] Waiting for soul-demo pod..."
until k3s kubectl get pods -l app=soul-demo --no-headers 2>/dev/null | grep -q "Running"; do
sleep 3
done
echo "[entrypoint] soul-demo is running."
echo "[entrypoint] Starting neuron-web on port ${PORT:-8080}..."
exec /usr/local/bin/neuron-web exec /usr/local/bin/neuron-web