Skip to content

Latest commit

 

History

History
135 lines (98 loc) · 13.7 KB

operations.md

File metadata and controls

135 lines (98 loc) · 13.7 KB

Operating Gantry locally

Scope and prerequisites

This repository uses a dedicated WSL2 distribution named gantry-design10, Ubuntu Base 24.04.4, with its VHDX under <checkout>\.gantry\wsl. Docker Engine and K3s run inside it; Docker Desktop is not required. Windows needs working WSL2/virtualization, Node/npm and the repository dependencies. Run commands from the repository root. Scripts resolve checkout paths automatically. The installed WSL virtual disk is registered at its original host location, so do not move that directory while the installation depends on it. The existing distro name and resource labels remain stable runtime identifiers.

Maintain C >=25 GB and D >=35 GB free. Scripts stop heavyweight work conservatively at C <=30 GiB or D <=40 GiB. Downloads, builders, source, images, runtime storage and scanner databases use D. Read resource-budget.md before provisioning. Builds run serially; do not start concurrent Golden Path verification jobs.

Start the existing installation

./scripts/platform/Start-Local.ps1
npm run build
npm run start -- --hostname 127.0.0.1 --port 3000

The startup script measures space, maintains a hidden WSL keepalive, starts Docker/K3s and existing database/metrics containers, starts the production control plane and telemetry helpers, and checks readiness. The frontend stays in the terminal that started it. Open http://127.0.0.1:3000. Close that terminal's server with Ctrl+C when finished.

For private local login retrieval, in your own terminal:

wsl -d gantry-design10 -- /opt/gantry/bin/gantry credentials

This derives passwords in memory and displays them only in your private terminal; do not redirect its output into a file, log, report or Git. A 32-byte cryptographically random root-private key and a domain-separated HMAC-SHA256 derivation give each local account a distinct 43-character credential. PostgreSQL stores only bcrypt hashes; the running API cannot read the derivation key. The key is an operator secret and must be protected like an administrator credential. Account handles are developer, lead, platform, reader. Lead operates its team's production services; platform can operate all local teams; developer can work within its team outside production; reader can inspect. Ownership changes require platform capability. Gantry settings can sign out; logout invalidates the durable session and open SSE stream.

First installation sequence

This exact environment was assembled and exercised incrementally. CLEAN-ROOM REINSTALL: NOT EXECUTED. No clean-room claim is made. The scripts capture the setup actions instead of relying on shell history.

The existing dedicated distro was actually terminated and started again with Start-Local.ps1; all Deployments, the production API, consumer/resource identities and state recovered. This restart found missing kmod, libpam-systemd and dbus-user-session packages in Ubuntu Base. They are now installed and included in install-runtime.sh. The startup wrapper checks native exit codes and preserves WSL warnings without confusing stderr with a failed exit. This executed restart is distinct from a fresh reinstall.

./scripts/platform/Initialize-WSL.ps1
$gantryProject = (wsl -d gantry-design10 --exec wslpath -a (Get-Location).Path).Trim()
wsl -d gantry-design10 -- bash "$gantryProject/scripts/platform/install-runtime.sh"
wsl --terminate gantry-design10
# Launch a hidden keepalive after enabling systemd; Start-Local performs this on later starts.
Start-Process wsl.exe -ArgumentList '-d gantry-design10 -- sleep infinity' -WindowStyle Hidden
wsl -d gantry-design10 -- bash "$gantryProject/scripts/platform/install-k3s.sh"
wsl -d gantry-design10 -- bash "$gantryProject/scripts/platform/start-database.sh"
wsl -d gantry-design10 -- bash "$gantryProject/scripts/platform/install-platform.sh"
wsl -d gantry-design10 -- bash "$gantryProject/scripts/platform/start-git.sh"
wsl -d gantry-design10 -- bash "$gantryProject/scripts/platform/start-telemetry.sh"
wsl -d gantry-design10 -- bash "$gantryProject/scripts/platform/build-control-plane.sh"
wsl -d gantry-design10 -- bash "$gantryProject/scripts/platform/harden-runtime.sh"
npm ci
npm run build
npm run start -- --hostname 127.0.0.1 --port 3000

Only terminate the named disposable distro when instructed; never use global WSL shutdown or unregister an unrelated distro. Initial scripts download maintained public releases and verify available official checksums. platform/template-versions.json pins application dependency versions; image metadata and verification evidence record the actual artifacts. A fresh installation may resolve newer OS package updates, so repeat the gates.

Configuration and state

Location Meaning
/opt/gantry/secrets/admin.env Migration/bootstrap database owner credentials, root-readable only
/opt/gantry/secrets/control-plane.env Runtime database URL, allowed origins, bind address and telemetry query URLs; systemd reads it for the restricted process
/opt/gantry/secrets/bootstrap.key Root-private random operator derivation key; no plaintext login-password file
/opt/gantry/runtime/kubeconfig Namespace-scoped client certificate, expires after 30 days
/opt/gantry/workspace/sources Generated, developer-editable service repositories
/opt/gantry/workspace/desired Local Git desired-state source served read-only in Kubernetes
/opt/gantry/workspace/evidence Bounded per-service build logs
/opt/gantry/workspace/control-plane.log JSON control-plane logs, rotated every five minutes when above 5 MB; three rotations
.gantry/evidence Raw gate results, screenshots, scans, failure matrix and resource measurements; ignored by Git

Important environment variables: GANTRY_DATABASE_URL, GANTRY_LISTEN, GANTRY_WORKSPACE, GANTRY_PROJECT, GANTRY_ORIGINS, GANTRY_OTLP_ENDPOINT, GANTRY_PROMETHEUS, GANTRY_JAEGER. Runtime defaults are local. The build script maintains /opt/gantry/project as a link to the checkout; GANTRY_PROJECT can override that path. NEXT_PUBLIC_GANTRY_MODE=demo is an explicit frontend test setting; omit it for real integration. Loopback HTTP uses HttpOnly/SameSite cookies and CSRF protection; configure the control-plane secure-cookie setting when introducing HTTPS. No TLS/public ingress deployment was performed.

Port Local purpose
3000 Production-built Gantry frontend on Windows loopback
8080 Go API on WSL loopback, proxied by Next /api/v1/*
5432 Control-plane PostgreSQL on WSL loopback
6443 K3s API inside the dedicated WSL environment
9090 Prometheus on WSL loopback
4318 / 16686 Jaeger OTLP / query via loopback port-forward
3100 / 3200 Isolated protected production / Turbopack tests

Migrations, restart and recovery

build-control-plane.sh formats/tests/builds a production binary, applies versioned migrations as owner, bootstraps reference metadata without recreating state, configures restricted runtime credentials/RBAC and restarts the service. Migrations use a database lock and recorded versions. Reapplying is a no-op; failure stops startup. Down migrations are intentionally unsupported. Forward fixes or a reviewed metadata restore are the recovery path; startup never drops or recreates the production schema.

The one-time legacy credential migration rotates the four local account hashes transactionally, invalidates their existing sessions, records four safe audit events and removes the old plaintext transfer. Subsequent ordinary bootstrap preserves passwords and sessions. Do not replace the derivation key alone: that would change operator-derived credentials without changing existing hashes. The key is retained with the private local operator state; recovery requires both protected operator state and the database.

$gantryProject = (wsl -d gantry-design10 --exec wslpath -a (Get-Location).Path).Trim()
wsl -d gantry-design10 -- bash "$gantryProject/scripts/platform/build-control-plane.sh"
wsl -d gantry-design10 -- systemctl status gantry-control-plane --no-pager
wsl -d gantry-design10 -- kubectl --kubeconfig /etc/rancher/k3s/k3s.yaml get pods -A

Pending workflows are durable. Restart releases the worker's advisory lock and resumes or safely terminates after its bounded interruption count. Failed resource/creation workflows have explicit retry controls. Resolve the actual subsystem error before retrying. A policy rejection does not commit unsafe desired state. Use Gantry's recommended fix or correct source/configuration and deploy again.

If GitOps drifts, inspect the environment's desired and observed revisions and field differences, then Sync to Git. Do not overwrite desired source with arbitrary live state. If telemetry is unavailable, Gantry reports unavailable/stale or no samples; restore the named backend and generate a new bounded test window.

Verification commands

./scripts/platform/Measure-Resources.ps1 -Phase 'before-verification'
$gantryProject = (wsl -d gantry-design10 --exec wslpath -a (Get-Location).Path).Trim()
wsl -d gantry-design10 -- bash "$gantryProject/scripts/platform/test-control-plane.sh"
wsl -d gantry-design10 -- bash "$gantryProject/scripts/platform/verify-paths.sh"
wsl -d gantry-design10 -- python3 "$gantryProject/scripts/platform/verify-admission.py"
wsl -d gantry-design10 -- python3 "$gantryProject/scripts/platform/failure-matrix.py"
wsl -d gantry-design10 -- python3 "$gantryProject/scripts/platform/extended-verification.py"
wsl -d gantry-design10 -- python3 "$gantryProject/scripts/platform/final-state-audit.py"
wsl -d gantry-design10 -- python3 "$gantryProject/scripts/platform/final-telemetry-audit.py"
npx playwright test --config playwright.platform.config.ts

The failure scripts intentionally mutate only named Gantry consumers and restore or safely reject them. Run them serially, with no overlapping drift/failure scenario. The platform browser suite creates a real Go service and Redis claim: it consumes the bounded local capacity. Do not rerun it indefinitely or increase the capacity just to avoid cleanup. Inspect existing evidence first.

For source-only frontend regressions use the explicit demo mode commands in README. Real platform E2E never uses the mock adapter. Browser traces/HAR/video are disabled for real login flows to avoid capturing credentials.

If port 3000 is occupied, run the real frontend on the already-allowed loopback port 3100 and set $env:PLAYWRIGHT_BASE_URL='http://127.0.0.1:3100' before the platform browser suite. Stop the fixture production server first; it also uses port 3100. Remove the variable after testing.

package-evidence.py validates the saved acceptance records and writes docs/evidence-ledger.json with hashes of selected retained raw evidence. It packages existing executed records; it does not run or replace the gates. The final accepted frontend command exits are recorded in frontend-verification-final.json, alongside production/dev Playwright JSON and build logs. Running new mutation tests changes the demo state and evidence; repeat the affected state/recovery audit before packaging a new report.

Practical demonstration

Sign in as platform or lead, inspect checkout-api and inventory-api, open production environment/revision/readiness, resources, Scorecard, runbooks and activity. Generate a bounded traffic sample to populate the local SLO window:

$gantryProject = (wsl -d gantry-design10 --exec wslpath -a (Get-Location).Path).Trim()
wsl -d gantry-design10 -- python3 "$gantryProject/scripts/platform/traffic-service.py" checkout-api production

This sends 100 requests at concurrency four, including four deliberate 500s. The resulting SLO breach is real local test evidence, not historical production performance. Open Observability for metrics, structured logs and real Jaeger trace IDs. Existing rejected deployments remain inspectable with remediation. Use the remaining service capacity for a new Golden Path demonstration.

Safe storage and shutdown

Measure with Measure-Resources.ps1 and docker system df inside the named distro. The Docker builder has bounded GC; Prometheus retention and logs are bounded. Jaeger is in-memory. Preserve generated source, desired Git, PostgreSQL/PVC data, current workload images and evidence for the demo. Do not run global Docker prune or delete unrelated user data.

To pause the demo, stop the frontend and use wsl --terminate gantry-design10 after stopping the hidden keepalive. This preserves the VHDX and state. Destructive teardown (wsl --unregister gantry-design10, removal of its VHDX, volumes or repositories) is not part of normal startup, is not executed automatically, and requires deliberately accepting loss of this local demo and its credentials/state.