mirror of
https://github.com/OpenStaticFish/MicroServices.git
synced 2026-10-13 06:35:12 +00:00
Add Tilt reset commands
This commit is contained in:
@@ -16,6 +16,8 @@
|
|||||||
- `nix run .#setup-kind` — creates/selects the `kind-openstaticfish` Kind cluster.
|
- `nix run .#setup-kind` — creates/selects the `kind-openstaticfish` Kind cluster.
|
||||||
- `nix run .#tilt -- up` — deploys all services with live reload.
|
- `nix run .#tilt -- up` — deploys all services with live reload.
|
||||||
- `nix run .#tilt -- down` — tears down Tilt-managed resources.
|
- `nix run .#tilt -- down` — tears down Tilt-managed resources.
|
||||||
|
- `nix run .#tilt-up` — nukes stale Tilt + Kind state, creates/reuses Kind cluster, sets kube context, then `tilt up`. Use this after switching worktrees or crashes.
|
||||||
|
- `nix run .#tilt-down` — kills any Tilt process on port 10350 and deletes the Kind cluster.
|
||||||
- `nix develop` — enters the dev shell with all deps (`tilt`, `kubectl`, `docker`, `go`, `jq`, `websocat`, etc.).
|
- `nix develop` — enters the dev shell with all deps (`tilt`, `kubectl`, `docker`, `go`, `jq`, `websocat`, etc.).
|
||||||
- `nix flake show` — sanity check after editing `flake.nix`.
|
- `nix flake show` — sanity check after editing `flake.nix`.
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,20 @@
|
|||||||
exec tilt "$@"
|
exec tilt "$@"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
tilt-up = pkgs.writeShellApplication {
|
||||||
|
name = "tilt-up";
|
||||||
|
runtimeInputs = with pkgs; [ docker kind kubectl tilt iproute2 ];
|
||||||
|
text = ''
|
||||||
|
exec bash ${./scripts/tilt-up} "$@"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
tilt-down = pkgs.writeShellApplication {
|
||||||
|
name = "tilt-down";
|
||||||
|
runtimeInputs = with pkgs; [ docker kind kubectl tilt iproute2 ];
|
||||||
|
text = ''
|
||||||
|
exec bash ${./scripts/tilt-down} "$@"
|
||||||
|
'';
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
@@ -55,17 +69,16 @@
|
|||||||
echo "-----------------------------------------"
|
echo "-----------------------------------------"
|
||||||
|
|
||||||
# --- Tilt Commands ---
|
# --- Tilt Commands ---
|
||||||
# Create/select the local Kind cluster first:
|
# Nuke stale state + full restart (recommended after worktree switch):
|
||||||
# setup-kind
|
# nix run .#tilt-up
|
||||||
# nix run .#setup-kind
|
|
||||||
#
|
#
|
||||||
# Start the development environment:
|
# Nuke everything (Tilt + Kind cluster):
|
||||||
|
# nix run .#tilt-down
|
||||||
|
#
|
||||||
|
# Start Tilt (assumes Kind cluster + context already set up):
|
||||||
# tilt up
|
# tilt up
|
||||||
# nix run .#tilt -- up
|
# nix run .#tilt -- up
|
||||||
#
|
#
|
||||||
# Tear down resources:
|
|
||||||
# tilt down
|
|
||||||
#
|
|
||||||
# View Tilt UI:
|
# View Tilt UI:
|
||||||
# tilt ui
|
# tilt ui
|
||||||
#
|
#
|
||||||
@@ -96,6 +109,8 @@
|
|||||||
echo "Available commands:"
|
echo "Available commands:"
|
||||||
echo " setup-kind - Create/select local Kind cluster"
|
echo " setup-kind - Create/select local Kind cluster"
|
||||||
echo " tilt up - Start dev environment"
|
echo " tilt up - Start dev environment"
|
||||||
|
echo " tilt-up - Nuke stale state, create Kind cluster, tilt up"
|
||||||
|
echo " tilt-down - Nuke Tilt + Kind cluster"
|
||||||
echo " tilt down - Stop dev environment"
|
echo " tilt down - Stop dev environment"
|
||||||
echo " kubectl ... - Interact with k8s cluster"
|
echo " kubectl ... - Interact with k8s cluster"
|
||||||
echo " docker ... - Interact with containers"
|
echo " docker ... - Interact with containers"
|
||||||
@@ -108,6 +123,7 @@
|
|||||||
# --- Command wrappers ---
|
# --- Command wrappers ---
|
||||||
# Run with: nix run .#setup-kind
|
# Run with: nix run .#setup-kind
|
||||||
# Run with: nix run .#tilt -- up
|
# Run with: nix run .#tilt -- up
|
||||||
|
# Run with: nix run .#tilt-up
|
||||||
apps = {
|
apps = {
|
||||||
setup-kind = {
|
setup-kind = {
|
||||||
type = "app";
|
type = "app";
|
||||||
@@ -118,6 +134,16 @@
|
|||||||
type = "app";
|
type = "app";
|
||||||
program = "${tilt-dev}/bin/tilt-dev";
|
program = "${tilt-dev}/bin/tilt-dev";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tilt-up = {
|
||||||
|
type = "app";
|
||||||
|
program = "${tilt-up}/bin/tilt-up";
|
||||||
|
};
|
||||||
|
|
||||||
|
tilt-down = {
|
||||||
|
type = "app";
|
||||||
|
program = "${tilt-down}/bin/tilt-down";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
cluster_name="openstaticfish"
|
||||||
|
|
||||||
|
echo "Nuking Tilt + Kind..."
|
||||||
|
|
||||||
|
# 1. Kill whatever is holding port 10350. 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
|
||||||
|
|
||||||
|
# 2. Delete the Kind cluster. This nukes all Tilt-managed resources too.
|
||||||
|
echo "Deleting Kind cluster '$cluster_name'..."
|
||||||
|
kind delete cluster --name "$cluster_name" 2>/dev/null || true
|
||||||
|
|
||||||
|
echo "Nuked."
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#!/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 "$@"
|
||||||
Reference in New Issue
Block a user