#!/bin/bash # The shared `spr` kind cluster [up|down|status] (default status). # # Usage: # ./ctrl/cluster.sh up # create the cluster (no-op if it exists) # ./ctrl/cluster.sh down # delete it (drops every room's namespace) # ./ctrl/cluster.sh status # what's running on it # # spr depends on rig, never the other way round. Building and deleting a cluster # is rig's job, so up and down hand straight to rig/ctrl/cluster.sh, carrying the # four things that make this cluster spr's rather than rig's defaults: # # CLUSTER=spr rooms deploy into the kind-spr context # KIND_CONFIG spr's own shape, which maps the rooms' gateway NodePorts # REGISTRY_MODE=none rooms load images straight into the node # PROFILE=minimal pinned here, so a change to rig's own ctrl/.env can never # quietly add addons to spr's cluster # # status stays here: it answers a question about rooms, not about the cluster. set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" RIG_CTRL="$SCRIPT_DIR/../rig/ctrl" rig() { CLUSTER=spr \ KIND_CONFIG="$SCRIPT_DIR/k8s/kind-config.yaml" \ REGISTRY_MODE=none \ PROFILE=minimal \ bash "$RIG_CTRL/cluster.sh" "$@" } case "${1:-status}" in up) rig up echo echo "Per-room deploy:" echo " cd gen/ && ./ctrl/k8s-up.sh" ;; down) rig down ;; status) if ! kind get clusters 2>/dev/null | grep -qx spr; then echo "No 'spr' kind cluster — run: make cluster up" exit 0 fi kubectl --context kind-spr get namespaces -l soleprint-room echo kubectl --context kind-spr get pods -A -l soleprint-room ;; *) echo "Unknown subcommand: $1" >&2 echo "Usage: cluster.sh [up|down|status]" >&2 exit 1 ;; esac