#!/usr/bin/env bash set -euo pipefail cluster_name="openstaticfish" if [ "${1:-}" = "up" ]; then shift fi echo "Nuking stale Tilt + Kind state..." # 1. Nuke stale tilt + kind. Do not call `tilt down` here: # it can hang when the kube context points at a dead Kind API server. pid=$(ss -tlnp 'sport = :10350' 2>/dev/null | grep -oP 'pid=\K[0-9]+' | head -1 || true) if [ -n "$pid" ]; then echo "Killing process on port 10350: $pid" kill "$pid" 2>/dev/null || true fi echo "Deleting Kind cluster '$cluster_name'..." kind delete cluster --name "$cluster_name" 2>/dev/null || true # 2. Ensure Docker is running docker info >/dev/null 2>&1 || { echo "Docker is not running."; exit 1; } # 3. Fresh cluster echo "Creating Kind cluster '$cluster_name'..." kind create cluster --name "$cluster_name" kubectl config use-context "kind-$cluster_name" # 4. Go echo "Starting Tilt..." exec tilt up "$@"