@@ -141,21 +141,15 @@ run_act() {
141141}
142142
143143# ─── Cleanup ─────────────────────────────────────────────────────────────────
144- # Two acts start background port-forwards: trace (to graphql-gateway, while the
145- # query is in flight) and topology (to Kiali, kept open through the discussion).
146- # Tear them down on exit no matter how we got there (Ctrl-C, normal exit,
147- # failure).
148- KIALI_PF=" "
144+ # The trace act starts a temporary port-forward to graphql-gateway; tear it
145+ # down on exit. Persistent UI forwards (Grafana, Kiali, etc.) are managed
146+ # by port-forward-ui.sh and survive this script.
149147TRACE_PF=" "
150148cleanup () {
151149 if [[ -n " $TRACE_PF " ]] && kill -0 " $TRACE_PF " 2> /dev/null; then
152150 printf ' \n%s cleaning up trace port-forward (pid %s)%s\n' " $DIM " " $TRACE_PF " " $RST "
153151 kill " $TRACE_PF " 2> /dev/null || true
154152 fi
155- if [[ -n " $KIALI_PF " ]] && kill -0 " $KIALI_PF " 2> /dev/null; then
156- printf ' \n%s cleaning up Kiali port-forward (pid %s)%s\n' " $DIM " " $KIALI_PF " " $RST "
157- kill " $KIALI_PF " 2> /dev/null || true
158- fi
159153}
160154trap cleanup EXIT
161155trap ' printf "\n%sinterrupted%s\n" "$RED" "$RST"; exit 130' INT
@@ -275,6 +269,11 @@ ${BOLD}${BLU}╔═════════════════════
275269INTRO
276270
277271(( PREFLIGHT == 1 )) && preflight
272+
273+ # Start persistent UI port-forwards (Grafana, Prometheus, Kiali, OpenMetadata)
274+ # so the dashboards are available throughout the walkthrough.
275+ ./scripts/port-forward-ui.sh
276+
278277prompt_enter " press Enter to start"
279278
280279# ─── ACT 1 · TRACE ───────────────────────────────────────────────────────────
@@ -402,6 +401,16 @@ if want_act scale; then
402401fi
403402
404403# ─── ACT 3 · CANARY ──────────────────────────────────────────────────────────
404+ # Guard: ensure order-service v1 is deployed — earlier demos (demo-order.sh,
405+ # demo-discovery.sh) uninstall it on success (CAP-008), and the canary act
406+ # needs it as the v1 baseline.
407+ if want_act canary; then
408+ if ! kubectl get deployment order-service -n " $NS " > /dev/null 2>&1 ; then
409+ info " order-service not deployed — restoring for canary act"
410+ helm upgrade --install order-service charts/capstone/charts/order-service -n " $NS " > /dev/null
411+ kubectl rollout status deploy/order-service -n " $NS " --timeout=120s > /dev/null
412+ fi
413+ fi
405414
406415if want_act canary; then
407416 act_header " canary" " Canary a contract — v1 → v2, by weight" \
@@ -449,20 +458,8 @@ if want_act topology; then
449458 prompt_enter " press Enter to verify Kiali"
450459 run_act " topology (smoke)" ./demos/demo-kiali.sh || exit 1
451460
452- narrate " now opening a port-forward to Kiali for you to show in the browser "
461+ narrate " Kiali is already port-forwarded (port-forward-ui.sh) "
453462 info " http://localhost:20001/kiali (Graph → namespace: capstone)"
454- info " the port-forward stays open until this script exits (Ctrl-C or end of walkthrough)"
455- # background port-forward; cleanup trap kills it on any exit
456- kubectl port-forward -n " $ISTIO_SYSTEM " svc/kiali 20001:20001 > /dev/null 2>&1 &
457- KIALI_PF=$!
458- # give it a couple seconds to bind, then probe
459- for _ in 1 2 3 4 5 6 7 8 9 10; do
460- if curl -fsS http://127.0.0.1:20001/kiali/healthz > /dev/null 2>&1 ; then
461- printf ' %s ✓ Kiali port-forward live at http://localhost:20001/kiali%s\n' " $GRN " " $RST "
462- break
463- fi
464- sleep 1
465- done
466463
467464 narrate " to make EDGES appear in the graph, generate some traffic:"
468465 info " in another shell: for i in {1..40}; do ./demos/demo-trace-flow.sh >/dev/null; done"
@@ -476,8 +473,5 @@ printf '\n%s%s══════════════════════
476473printf ' %s%s walkthrough complete · %d / %d acts run%s\n' " $BOLD " " $GRN " " $ACT_NUM " " $ACT_TOTAL " " $RST "
477474printf ' %s%s═══════════════════════════════════════════════════════════════════════%s\n\n' " $BOLD " " $GRN " " $RST "
478475
479- if want_act topology && [[ -n " $KIALI_PF " ]] && kill -0 " $KIALI_PF " 2> /dev/null; then
480- printf ' %s Kiali port-forward is still up (pid %s) — http://localhost:20001/kiali%s\n' " $DIM " " $KIALI_PF " " $RST "
481- printf ' %s press Enter to tear it down and exit, or Ctrl-C to keep the script alive until you do%s\n\n' " $DIM " " $RST "
482- prompt_enter " press Enter to exit"
483- fi
476+ printf ' %s UI port-forwards remain active (Grafana :3000, Prometheus :9091, Kiali :20001, OpenMetadata :8585)%s\n' " $DIM " " $RST "
477+ printf ' %s stop them with: ./scripts/port-forward-ui.sh --stop%s\n' " $DIM " " $RST "
0 commit comments