diff --git a/infra/workstation/README.md b/infra/workstation/README.md new file mode 100644 index 0000000..c47f0fd --- /dev/null +++ b/infra/workstation/README.md @@ -0,0 +1,35 @@ +# Workstation: collector and visz + +The demo's collector and visz run on the laptop you present from, not in the K3s cluster: the cluster nodes are small and far away, and the collector does the analysis while visz renders it. The sidecars in the cluster report to the laptop over Tailscale. + +``` +K3s cluster (peers only) this laptop (Docker) +foodbolt pods + spctrld ──Tailscale──▶ collector :9400 (ghcr.io/cap-theorem/spectral-collector) + visz :9500 ──▶ browser +``` + +## Start + +From this directory, with Docker running, and `cap-theorem/visz` checked out next to this repository (or `VISZ_DIR` pointing at it): + +```bash +docker compose up -d --build +``` + +Then open http://localhost:9500. visz is built to read the collector at http://localhost:9400. If your browser remembers an older collector URL, open http://localhost:9500/?collector=http://localhost:9400 once. + +`COLLECTOR_TAG` picks the collector image (default `sha-297689b`). Keep it in step with the `SPCTRLD_TAG` the peers run. The collector drops a node one minute after its last report (`--stale-after=1m`). + +Peers started with `scripts/demo` report to `http://:9400` by default. Check that the cluster can reach it: + +```bash +curl -s http://$(tailscale ip -4):9400/v1/summary +``` + +## Stop + +```bash +docker compose down +``` + +The collector keeps the graph in memory only, so restarting it starts from an empty graph that fills again within one report interval (about 30 s). While this laptop sleeps or is off the tailnet, the sidecars' reports fail and the graph goes stale. diff --git a/infra/workstation/compose.yaml b/infra/workstation/compose.yaml new file mode 100644 index 0000000..c6836e0 --- /dev/null +++ b/infra/workstation/compose.yaml @@ -0,0 +1,25 @@ +name: spectral-workstation + +services: + collector: + image: ghcr.io/cap-theorem/spectral-collector:${COLLECTOR_TAG:-sha-297689b} + pull_policy: always + command: + - --listen-addr=:9400 + - --stale-after=1m + - --log-format=json + ports: + - "9400:9400" + restart: unless-stopped + + visz: + build: + context: ${VISZ_DIR:-../../../visz} + args: + VITE_COLLECTOR_URL: http://localhost:9400 + image: visz:local + ports: + - "9500:80" + depends_on: + - collector + restart: unless-stopped diff --git a/scripts/demo b/scripts/demo new file mode 100755 index 0000000..0c6bf2a --- /dev/null +++ b/scripts/demo @@ -0,0 +1,340 @@ +#!/usr/bin/env bash +set -euo pipefail + +fail() { printf 'error: %s\n' "$*" >&2; exit 1; } + +here=$(cd "$(dirname "$0")" && pwd) +namespace=foodbolt +services=(gateway orders restaurants payments dispatch) + +export KUBECONFIG=${KUBECONFIG:-$HOME/.kube/spectral-k3s.yaml} +export FOODBOLT_RUN=${FOODBOLT_RUN:-demo-1} +export SPCTRLD_TAG=${SPCTRLD_TAG:-sha-297689b} +export FOODBOLT_TAG=${FOODBOLT_TAG:-sha-5be11a9} +if [[ -z ${SPECTRAL_COLLECTOR_URL+x} ]]; then + ts_ip=$(tailscale ip -4 2>/dev/null | head -1) || true + [[ -n $ts_ip ]] || fail 'cannot find this machine'"'"'s Tailscale IP; set SPECTRAL_COLLECTOR_URL' + export SPECTRAL_COLLECTOR_URL="http://$ts_ip:9400" +fi +ssh_user=${DEMO_SSH_USER:-ubuntu} +run_label="spectral.dev/run=$FOODBOLT_RUN" +worker_label="$run_label,spectral.dev/role=worker" + +k() { command kubectl -n "$namespace" "$@"; } + +usage() { + cat <&1) + clear + printf '%s run %s\n\n%s\n' "$(date +%T)" "$FOODBOLT_RUN" "$out" + sleep 2 + done +} + +cmd_machines() { + local nodes counts + nodes=$(command kubectl get nodes -o 'jsonpath={range .items[*]}{.metadata.name}{"\t"}{.status.addresses[?(@.type=="InternalIP")].address}{"\t"}{.status.conditions[?(@.type=="Ready")].status}{"\n"}{end}') + counts=$(k get pods -l "$run_label" --field-selector='status.phase=Running' -o 'jsonpath={range .items[*]}{.spec.nodeName}{"\n"}{end}' | sort | uniq -c) + printf '%-20s %-16s %-6s %s\n' MACHINE TAILSCALE_IP READY PEERS + while IFS=$'\t' read -r name ip ready; do + n=$(awk -v m="$name" '$2 == m { print $1 }' <<<"$counts") + printf '%-20s %-16s %-6s %s\n' "$name" "$ip" "$ready" "${n:-0}" + done <<<"$nodes" +} + +cmd_logs() { + local pod container + pod=$(resolve_pod "${1:?usage: logs POD [app|spctrld]}") + container=$(k get pod "$pod" -o 'jsonpath={.metadata.labels.app}') + if [[ ${2:-app} == spctrld || $container == spctrld-seed ]]; then + container=spctrld + fi + k logs -f --tail=100 "$pod" -c "$container" +} + +cmd_up() { + local svc=${1:?usage: up SERVICE [N] [MACHINE]} n=${2:-1} machine=${3:-} + is_service "$svc" || fail "unknown service $svc; pick one of: ${services[*]}" + check_count "$n" + "$here/foodbolt-pods" "$svc" "$n" $machine +} + +cmd_up_random() { + local n=${1:?usage: up-random N [MACHINE]} machine=${2:-} svc i + check_count "$n" + local -a picks=() + for ((i = 0; i < n; i++)); do + picks+=("${services[RANDOM % ${#services[@]}]}") + done + for svc in "${services[@]}"; do + local count=0 p + for p in "${picks[@]}"; do + [[ $p == "$svc" ]] && count=$((count + 1)) + done + if ((count > 0)); then + "$here/foodbolt-pods" "$svc" "$count" $machine + fi + done +} + +cmd_up_all() { + local n=${1:-1} svc + check_count "$n" + for svc in "${services[@]}"; do + "$here/foodbolt-pods" "$svc" "$n" + done +} + +delete_pods() { + local mode=$1 + shift + (($# > 0)) || fail "name at least one pod" + local -a pods=() + local p + for p in "$@"; do + pods+=("$(resolve_pod "$p")") + done + if [[ $mode == crash ]]; then + k delete pod "${pods[@]}" --grace-period=0 --force --wait=false 2>&1 | grep -v '^Warning: Immediate deletion' + else + k delete pod "${pods[@]}" --wait=false + fi +} + +cmd_random() { + local mode=$1 n=${2:?usage: $1-random N [SERVICE]} svc=${3:-} victims + check_count "$n" + if [[ -n $svc ]]; then + is_service "$svc" || fail "unknown service $svc" + fi + victims=$(live_workers "$svc" | pick_random "$n") + [[ -n $victims ]] || fail "no live ${svc:-worker} pods to kill" + if (($(wc -l <<<"$victims") < n)); then + printf 'only %s live %s pods; killing all of them\n' "$(wc -l <<<"$victims" | tr -d ' ')" "${svc:-worker}" >&2 + fi + delete_pods "$mode" $victims +} + +stop_container() { + local which=$1 pod=$2 hard=${3:-} container cid host timeout=10 + pod=$(resolve_pod "$pod") + if [[ $which == app ]]; then + container=$(k get pod "$pod" -o 'jsonpath={.metadata.labels.app}') + [[ $container != spctrld-seed ]] || fail "$pod is the seed and has only spctrld; use kill-spctrld" + else + container=spctrld + fi + if [[ -n $hard ]]; then + [[ $hard == --hard ]] || fail "unknown flag $hard" + timeout=0 + fi + cid=$(k get pod "$pod" -o "jsonpath={.status.containerStatuses[?(@.name==\"$container\")].containerID}") + cid=${cid#containerd://} + [[ -n $cid ]] || fail "$container in $pod has no running container" + host=$(k get pod "$pod" -o 'jsonpath={.status.hostIP}') + ssh -o BatchMode=yes -o ConnectTimeout=5 "$ssh_user@$host" sudo -n k3s crictl stop -t "$timeout" "$cid" >/dev/null + printf 'stopped %s in %s on %s (%s)\n' "$container" "$pod" "$host" "$([[ $timeout == 0 ]] && echo SIGKILL || echo SIGTERM)" +} + +cmd_crash_machine() { + local machine=${1:?usage: crash-machine MACHINE} pods + command kubectl get node "$machine" >/dev/null 2>&1 || fail "no machine named $machine; see scripts/demo machines" + pods=$(k get pods -l "$run_label" --field-selector="spec.nodeName=$machine,status.phase=Running" -o 'jsonpath={range .items[*]}{.metadata.name}{"\n"}{end}') + [[ -n $pods ]] || fail "no live peers on $machine" + printf 'crashing %s peers on %s\n' "$(wc -l <<<"$pods" | tr -d ' ')" "$machine" + delete_pods crash $pods +} + +gateway_url() { + local port ip + port=$(k get service "gateway-$FOODBOLT_RUN" -o 'jsonpath={.spec.ports[0].nodePort}' 2>/dev/null) || true + [[ -n $port ]] || fail "run $FOODBOLT_RUN has no gateway; start one with: scripts/demo up gateway" + ip=$(command kubectl get nodes -o 'jsonpath={.items[0].status.addresses[?(@.type=="InternalIP")].address}') + printf 'http://%s:%s\n' "$ip" "$port" +} + +cmd_order() { + local n=${1:-1} who=${2:-} url i customer + check_count "$n" + local -a customers=(alice bob carol) + url=$(gateway_url) + for ((i = 0; i < n; i++)); do + customer=${who:-${customers[RANDOM % ${#customers[@]}]}} + curl -sS -m 15 -X POST "$url/v1/orders" \ + -H "Authorization: Bearer fb_test_$customer" \ + -H 'Content-Type: application/json' \ + -d '{"restaurant_id":"green-bowl","items":[{"item_id":"harvest-bowl","quantity":1}]}' | + CUSTOMER=$customer python3 -c ' +import json, os, sys +raw = sys.stdin.read() +try: + d = json.loads(raw) +except ValueError: + print(os.environ["CUSTOMER"].ljust(6), "bad response:", raw[:200]) + sys.exit(0) +if "error" in d: + e = d["error"] + print(os.environ["CUSTOMER"].ljust(6), "FAILED", e.get("message", e) if isinstance(e, dict) else e) + sys.exit(0) +hops = " -> ".join(h["service"] + "/" + h["instance"] + "@" + h["machine"] for h in d.get("trace", [])) +print(os.environ["CUSTOMER"].ljust(6), d.get("status", "?").ljust(10), d.get("order_id") or d.get("id") or "", hops) +' + done +} + +cmd_down() { + k delete pods,services -l "$run_label" --wait=false +} + +command=${1:-help} +shift || true +case $command in + status|ls) cmd_status ;; + watch) cmd_watch ;; + machines) cmd_machines ;; + graph) cmd_graph ;; + logs) cmd_logs "$@" ;; + up) cmd_up "$@" ;; + up-random) cmd_up_random "$@" ;; + up-all) cmd_up_all "$@" ;; + kill) delete_pods kill "$@" ;; + crash) delete_pods crash "$@" ;; + kill-random) cmd_random kill "$@" ;; + crash-random) cmd_random crash "$@" ;; + kill-app) stop_container app "$@" ;; + kill-spctrld) stop_container spctrld "$@" ;; + crash-machine) cmd_crash_machine "$@" ;; + order) cmd_order "$@" ;; + gateway) gateway_url ;; + down) cmd_down ;; + help|-h|--help) usage ;; + *) usage >&2; exit 1 ;; +esac diff --git a/scripts/demo.md b/scripts/demo.md new file mode 100644 index 0000000..410bf91 --- /dev/null +++ b/scripts/demo.md @@ -0,0 +1,60 @@ +# Demo controls + +`scripts/demo` drives one Foodbolt-on-Spectral run on the K3s cluster: look at it, add peers, kill them in every way that matters, and send orders through it. It builds on `scripts/foodbolt-pods`, so every peer is an unmanaged Pod with `restartPolicy: Never`: nothing you kill comes back unless you start it again. + +`scripts/demo help` lists every command with the defaults it will use. + +## Defaults + +| Variable | Default | +|---|---| +| `KUBECONFIG` | `~/.kube/spectral-k3s.yaml` | +| `FOODBOLT_RUN` | `demo-1` | +| `SPCTRLD_TAG` | `sha-297689b` | +| `FOODBOLT_TAG` | `sha-5be11a9` | +| `SPECTRAL_COLLECTOR_URL` | `http://:9400`, i.e. a collector running on your laptop | +| `DEMO_SSH_USER` | `ubuntu` | + +New peers report to `SPECTRAL_COLLECTOR_URL`, and `status` and `graph` read its summary from there. The collector must be reachable from the cluster over Tailscale, and it stops getting reports when your laptop sleeps. + +## Commands + +```fish +scripts/demo status # every pod, its machine, and whether the app and spctrld are up, dead or leaving +scripts/demo watch # the same, refreshed every 2s: keep this open on a second screen +scripts/demo machines # nodes, their Tailscale IPs, peers per node +scripts/demo graph # collector: nodes, edges, components, degree, spectral gap +scripts/demo logs orders-demo-1-kv # follow the service's logs; add spctrld for the sidecar's + +scripts/demo up orders 2 # two new orders peers +scripts/demo up dispatch 1 ip-172-31-23-240 # pinned to one machine +scripts/demo up-random 5 # five peers of random services +scripts/demo up-all # one of every service + +scripts/demo kill orders-demo-1-kv # graceful: SIGTERM, spctrld sends Leave +scripts/demo crash orders-demo-1-kv # instant: no Leave, peers must detect it +scripts/demo kill-random 3 # three random workers, gracefully +scripts/demo crash-random 2 payments # two random payments peers, instantly +scripts/demo kill-app payments-demo-1-n6 # stop only the service; spctrld keeps running +scripts/demo kill-spctrld orders-demo-1-c9 --hard # stop only the sidecar, with SIGKILL +scripts/demo crash-machine ip-172-31-23-240 # every peer on one machine, instantly + +scripts/demo order 10 # ten orders as random customers, each with its route +scripts/demo order 1 dave # dave's card is declined: expect a 402 +scripts/demo gateway # the gateway URL, for your own curl + +scripts/demo down # delete the whole run +``` + +A pod name can be shortened to any unique prefix. Random kills only pick live workers, never the seed pod; kill the seed by name if you want it gone. + +`kill-app` and `kill-spctrld` stop one container through `crictl` on the node, over SSH to the node's Tailscale IP, so you need SSH access as `ubuntu` with passwordless sudo, which the Ansible setup already gives you. Without `--hard`, the container gets SIGTERM and 10s to exit; with it, SIGKILL. The stopped container is never restarted, and `status` shows it as `dead()`. A pod whose service is dead keeps a live sidecar, so it stays in the overlay graph while its lease expires and lookups stop returning it; a pod whose sidecar is dead leaves the graph while its service keeps running and fails its lookups. + +`crash-machine` deletes pods; it does not stop the machine. To take a real node down, stop K3s on it (`sudo systemctl stop k3s-agent`) and note that its pods then sit in `Unknown` rather than disappearing. + +## Things to show + +- **Join**: `watch` in one terminal, `up-random 5` in another, and the collector's node count and gap update as the new peers join through any live peer. +- **Routing around failure**: `order 5`, then `crash-random 1 orders`, then `order 5` again: the routes change and orders keep succeeding. +- **Total loss of a service**: kill every `payments` peer and orders fail with `payments unavailable`; `up payments` and they succeed again within a lease. +- **Losing a machine**: `crash-machine` one node, then `graph`: the overlay stays in one component. diff --git a/scripts/foodbolt-pods b/scripts/foodbolt-pods new file mode 100755 index 0000000..28be64e --- /dev/null +++ b/scripts/foodbolt-pods @@ -0,0 +1,282 @@ +#!/usr/bin/env bash +# Create bare Foodbolt pods with Spectral sidecars for node-failure experiments. +# Usage: FOODBOLT_RUN=demo-1 SPCTRLD_TAG=sha-... FOODBOLT_TAG=sha-... \ +# ./scripts/foodbolt-pods SERVICE COUNT [KUBERNETES_HOSTNAME] +# Run again with the same FOODBOLT_RUN to add another service to the same peer network. +set -euo pipefail + +fail() { printf 'error: %s\n' "$*" >&2; exit 1; } + +[[ $# -ge 2 && $# -le 3 ]] || fail "usage: $0 SERVICE COUNT [KUBERNETES_HOSTNAME]" +svc=$1 +count=$2 +host=${3:-} + +case $svc in + gateway) port=8080 ;; + orders) port=8081 ;; + restaurants) port=8082 ;; + payments) port=8083 ;; + dispatch) port=8084 ;; + *) fail "unknown service: $svc" ;; +esac + +[[ $count =~ ^[1-9][0-9]*$ ]] && (( ${#count} <= 3 )) && (( count <= 500 )) || fail 'COUNT must be between 1 and 500' +: "${FOODBOLT_RUN:?set FOODBOLT_RUN to a run ID such as demo-1}" +: "${SPCTRLD_TAG:?set SPCTRLD_TAG to a published GHCR tag}" +: "${FOODBOLT_TAG:?set FOODBOLT_TAG to a published GHCR tag}" +[[ $FOODBOLT_RUN =~ ^[a-z0-9]([a-z0-9-]{0,28}[a-z0-9])?$ ]] || fail 'FOODBOLT_RUN must be a lowercase DNS label (up to 30 characters)' +for tag in "$SPCTRLD_TAG" "$FOODBOLT_TAG"; do + [[ $tag =~ ^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$ ]] || fail "invalid image tag: $tag" +done +[[ -z $host || $host =~ ^[a-z0-9]([-a-z0-9.]*[a-z0-9])?$ ]] || fail 'host must be a kubernetes.io/hostname label value' + +: "${SPECTRAL_COLLECTOR_URL?set SPECTRAL_COLLECTOR_URL to your collector, e.g. http://:9400, or to an empty string to disable reports}" +collector_url=$SPECTRAL_COLLECTOR_URL +collector_arg='' +if [[ -n $collector_url ]]; then + [[ $collector_url =~ ^https?://[a-zA-Z0-9._:/-]+$ ]] || fail 'invalid SPECTRAL_COLLECTOR_URL' + collector_arg=" - \"--collector-url=$collector_url\"" +fi + +namespace=foodbolt +seed_name="spctrld-seed-$FOODBOLT_RUN" +peers_name="spctrld-peers-$FOODBOLT_RUN" +gateway_name="gateway-$FOODBOLT_RUN" +selector="spectral.dev/run=$FOODBOLT_RUN" +node_selector='' +if [[ -n $host ]]; then + node_selector=$' nodeSelector:\n kubernetes.io/hostname: "'"$host"'"' +fi + +render_peers_service() { + cat </dev/null || fail 'kubectl is required' +k() { command kubectl --kubeconfig "$KUBECONFIG" "$@"; } + +api_server=$(k config view --minify -o 'jsonpath={.clusters[0].cluster.server}') +[[ $api_server == 'https://100.90.92.118:6443' ]] || fail "wrong cluster API server: $api_server" + +# The original Spectral Deployment must be scaled down or removed first. +spectral_namespace=$(k get namespace spectral -o name --ignore-not-found) || fail 'cannot check the spectral namespace' +if [[ -n $spectral_namespace ]]; then + old_pods=$(k -n spectral get pods -l 'app in (spctrld,spctrld-seed)' -o name) || fail 'cannot check existing Spectral pods' + [[ -z $old_pods ]] || fail 'old Spectral pods still exist in the spectral namespace; scale down both Deployments first' +fi + +if [[ -n $host ]]; then + [[ -n $(k get nodes -l "kubernetes.io/hostname=$host" -o name) ]] || fail "no node has kubernetes.io/hostname=$host; check kubectl get nodes -L kubernetes.io/hostname" +fi + +foodbolt_namespace=$(k get namespace "$namespace" -o name --ignore-not-found) || fail 'cannot check the foodbolt namespace' +if [[ -z $foodbolt_namespace ]]; then + k create namespace "$namespace" +fi +render_peers_service | k apply -f - + +live_peers=$(k -n "$namespace" get pods -l "$selector,spectral.dev/peer=true" --field-selector='status.phase!=Failed,status.phase!=Succeeded' -o name) || fail 'cannot check live peers' +if [[ -z $live_peers ]]; then + [[ -z $(k -n "$namespace" get pod "$seed_name" -o name --ignore-not-found) ]] || fail "run $FOODBOLT_RUN has no live peers but $seed_name still exists; clean up the run or pick a new FOODBOLT_RUN" + render_seed | k create -f - + k -n "$namespace" wait --for=condition=Ready "pod/$seed_name" --timeout=180s || fail "seed $seed_name is not Ready; inspect its pod events" + printf 'Started seed %s for run %s.\n' "$seed_name" "$FOODBOLT_RUN" +fi + +if [[ $svc == gateway ]]; then + render_gateway_service | k apply -f - +fi + +render_workers | k create -f - +printf 'Created %s %s pod(s) in run %s.\n' "$count" "$svc" "$FOODBOLT_RUN" +if [[ $svc == gateway ]]; then + node_port=$(k -n "$namespace" get service "$gateway_name" -o 'jsonpath={.spec.ports[0].nodePort}') + printf 'Gateway: http://:%s (e.g. http://100.90.92.118:%s)\n' "$node_port" "$node_port" +fi +printf 'Inspect: kubectl -n %s get pods -l %s -o wide\n' "$namespace" "$selector" +printf 'Clean up: kubectl -n %s delete pods,services -l %s\n' "$namespace" "$selector" diff --git a/scripts/foodbolt-pods.md b/scripts/foodbolt-pods.md new file mode 100644 index 0000000..4b0cd25 --- /dev/null +++ b/scripts/foodbolt-pods.md @@ -0,0 +1,61 @@ +# Bare Spectral/Foodbolt pods + +`scripts/foodbolt-pods` creates unmanaged Foodbolt Pods, each with a Spectral sidecar, for one peer network identified by `FOODBOLT_RUN`. Every Pod uses `restartPolicy: Never` and has no controller, so Kubernetes never restarts an exited container or replaces a Pod that was deleted or lost with its node. A peer exists only because someone ran the script. + +Every peer in a run is a seed. The headless Service `spctrld-peers-` selects all peers of the run, and each sidecar bootstraps through it. spctrld resolves that name again on every seed pull and when it finds itself isolated, so any live peer can admit a new one, and killing a particular peer never blocks joins. + +The first invocation for a run, when no peers are live, also starts a sidecar-only Pod, `spctrld-seed-`, so the first workers have someone to join. After that it is an ordinary peer: you can kill it like any other. If every peer in a run has died, clean up the run (see below) or use a new run ID; the script refuses to start a second, isolated seed next to the old one. + +## Prerequisites + +- A kubeconfig for the K3s cluster at `https://100.90.92.118:6443`. +- The old `spectral` Deployments scaled to zero. The script refuses to run while their pods exist and does not scale them down for you. +- Spectral's topology collector running on your laptop, from `infra/workstation` (see its README). The cluster nodes are small and far away, so the collector and visz run on the machine you present from, and the sidecars report to it over Tailscale. +- `SPECTRAL_COLLECTOR_URL` set to that collector as the cluster sees it, `http://:9400`, or to an empty string to start peers that do not report. `scripts/demo` sets it for you. + +## Usage + +From fish, in the repository root: + +```fish +set -gx KUBECONFIG "$HOME/.kube/spectral-k3s.yaml" +kubectl -n spectral scale deployment/spctrld --replicas=0 +kubectl -n spectral get pods # Wait until the old spctrld pods are gone. + +set -gx FOODBOLT_RUN demo-1 +set -gx SPCTRLD_TAG sha-297689b +set -gx FOODBOLT_TAG sha-abcdef1 # Replace with the published Foodbolt image tag. +set -gx SPECTRAL_COLLECTOR_URL http://(tailscale ip -4):9400 +env DRY_RUN=1 ./scripts/foodbolt-pods gateway 2 # Print the YAML without contacting Kubernetes. +./scripts/foodbolt-pods gateway 2 +./scripts/foodbolt-pods orders 3 +./scripts/foodbolt-pods restaurants 2 +./scripts/foodbolt-pods payments 2 +./scripts/foodbolt-pods dispatch 2 ip-172-31-23-240 # Pin to one machine. +kubectl -n foodbolt get pods -l spectral.dev/run=demo-1 -o wide +``` + +The optional third argument is a **Kubernetes hostname label value**, such as `ip-172-31-23-240`, not a Tailscale machine name. Check values with `kubectl get nodes -L kubernetes.io/hostname`. Without it, Kubernetes spreads workers across nodes. + +Starting `gateway` also creates the NodePort Service `gateway-` and prints its port; reach it from the tailnet at `http://100.90.92.118:`. + +## Killing peers + +```fish +kubectl -n foodbolt delete pod orders-demo-1-x7k2q # Graceful: spctrld sends Leave. +kubectl -n foodbolt delete pod orders-demo-1-x7k2q --grace-period=0 --force # Crash: no Leave. +``` + +Neither comes back. Foodbolt keeps state in memory per instance, so resources owned by a killed instance (orders, payments, tickets, deliveries) are gone with it and return 404. + +## Capacity + +Start with small batches. Each worker Pod requests 35m CPU and 40Mi memory across its two containers; 100 Pods request 3.5 CPUs and about 4 GiB. Actual usage may be higher, and the current three nodes have roughly 2 GiB each. Watch `kubectl top nodes` and Pod events before increasing the count. + +## Cleanup + +```fish +kubectl -n foodbolt delete pods,services -l spectral.dev/run=demo-1 +``` + +Do not reapply `infra/k8s/overlays/cloud` during a run: it restores the 20-replica `spctrld` Deployment.