|
| 1 | +--- |
| 2 | +title: Deployment Guide |
| 3 | +order: 16 |
| 4 | +--- |
| 5 | + |
| 6 | +# Frontier Admin Console — Deployment Guide |
| 7 | + |
| 8 | +How a [raystack/frontier](https://github.com/raystack/frontier) admin console deployment is built, |
| 9 | +configured, deployed, verified, and rolled back. Applies to any Helm-on-Kubernetes deployment. |
| 10 | + |
| 11 | +> **Everything here is illustrative except the `raystack/frontier` paths.** Hosts (`<admin-host>`, |
| 12 | +> `<connect-host>`), ports, filenames, pipeline details, and secrets tooling are placeholders — |
| 13 | +> substitute your deployment's actual values. Ports shown are the upstream defaults from |
| 14 | +> [`config/sample.config.yaml`](https://github.com/raystack/frontier/blob/main/config/sample.config.yaml). |
| 15 | +> Verified against `v0.112.1`; re-verify paths against the deployed tag. |
| 16 | +
|
| 17 | +**Contents** |
| 18 | + |
| 19 | +1. [How it works](#1-how-it-works) |
| 20 | +2. [Deploy to an environment](#2-deploy-to-an-environment) |
| 21 | +3. [Configure an environment](#3-configure-an-environment) |
| 22 | +4. [Admin login (bootstrap superuser)](#4-admin-login-bootstrap-superuser) |
| 23 | +5. [Verify a deployment](#5-verify-a-deployment) |
| 24 | +6. [Roll back](#6-roll-back) |
| 25 | +7. [Cut a release (upstream `frontier`)](#7-cut-a-release-upstream-frontier) |
| 26 | +8. [Gotchas](#8-gotchas) |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## 1. How it works |
| 31 | + |
| 32 | +Every procedure below follows from four facts: |
| 33 | + |
| 34 | +1. **The console is embedded in the backend.** A React/Vite SPA, compiled to static assets and baked |
| 35 | + into the Go binary at build time (`//go:embed all:dist`, `web/apps/admin/embed.go`). No Node.js |
| 36 | + in production. |
| 37 | +2. **One image serves every environment.** The SPA fetches its config at runtime from `GET /configs`; |
| 38 | + nothing environment-specific is compiled in. |
| 39 | +3. **Everything environment-specific lives outside the image** — each environment's Frontier config |
| 40 | + (the `ui:` block, `app.admin.bootstrap`, ingress, etc.), typically rendered at deploy time from a |
| 41 | + secrets backend and mounted into the pod as a ConfigMap. |
| 42 | +4. **Backend and console are one artifact** — they version, deploy, and roll back together. The |
| 43 | + console cannot roll back alone. |
| 44 | + |
| 45 | +``` |
| 46 | +raystack/frontier environment config |
| 47 | +───────────────── ────────────────── |
| 48 | +web/apps/admin frontier config (ui:, app.admin.bootstrap) |
| 49 | + │ vite build → dist/admin │ rendered from secrets at deploy time |
| 50 | + │ //go:embed │ |
| 51 | + ▼ ▼ |
| 52 | +docker.io/raystack/frontier:{tag} ──► helm upgrade → Kubernetes |
| 53 | + │ |
| 54 | + ▼ |
| 55 | + running pod: SPA + /configs + /frontier-connect proxy + API |
| 56 | +``` |
| 57 | + |
| 58 | +One binary runs two HTTP servers (`cmd/serve.go`), both exposed through the ingress: |
| 59 | + |
| 60 | +| Server | Config key | Default port | Serves | Ingress host | |
| 61 | +|---|---|---|---|---| |
| 62 | +| UI | `ui.port` | `8100` | SPA, `GET /configs`, `/frontier-connect/` proxy | `<admin-host>` | |
| 63 | +| Connect/API | `app.connect.port` | `8002` | ConnectRPC/gRPC, gRPC health, `GET /ping` | `<connect-host>` | |
| 64 | + |
| 65 | +Both are deliberately exposed: browsers use the admin host; API clients and automation use the |
| 66 | +Connect host directly. |
| 67 | + |
| 68 | +UI server routing (`pkg/server/server.go`): `/configs` returns the config JSON; `/frontier-connect/` |
| 69 | +reverse-proxies to `{app.host}:{app.connect.port}` with the prefix stripped; everything else serves |
| 70 | +the SPA with an `index.html` fallback. |
| 71 | + |
| 72 | +> **Local dev differs** — Vite serves `/configs` (from `configs.dev.json`) and proxies |
| 73 | +> `/frontier-connect`, with the SPA unbundled on `:5173`. Don't carry local ports or behaviour into |
| 74 | +> an environment; see the local-setup doc. |
| 75 | +
|
| 76 | +**Key paths upstream:** |
| 77 | + |
| 78 | +| Path | Purpose | |
| 79 | +|---|---| |
| 80 | +| `web/apps/admin` | Admin SPA (Vite `outDir: dist/admin`, `base: /`) | |
| 81 | +| `web/apps/admin/embed.go` | `//go:embed all:dist` → `var Assets embed.FS` | |
| 82 | +| `web/apps/admin/configs.dev.json` | Dev `/configs` payload | |
| 83 | +| `pkg/server/server.go` | `ServeUI` / `ServeConnect`, `/configs`, proxy, `/ping`, health | |
| 84 | +| `pkg/server/config.go` | `UIConfig`, `TerminologyConfig`, `ConnectConfig` | |
| 85 | +| `internal/bootstrap/bootstrapuser.go` | Superuser bootstrap | |
| 86 | +| [`config/sample.config.yaml`](https://github.com/raystack/frontier/blob/main/config/sample.config.yaml) | Annotated reference for every config key | |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## 2. Deploy to an environment |
| 91 | + |
| 92 | +A deploy renders the environment's config from the secrets backend, then runs `helm upgrade` with an |
| 93 | +explicitly chosen image tag. The contract, regardless of pipeline tooling: |
| 94 | + |
| 95 | +- **Each environment pins an image version** — an immutable `vX.Y.Z` tag. A pre-production |
| 96 | + environment may instead track a mutable tag rebuilt from upstream `main` (see |
| 97 | + [Roll back](#6-roll-back) for the consequence). |
| 98 | +- **The tag chosen at deploy time always wins.** The Helm values file may also carry an `image.tag`, |
| 99 | + but the deploy sets the tag explicitly — never read the values file as the deployed version. Keep |
| 100 | + it pinned to a real version anyway: it's the fallback for a manual `helm upgrade`, and the chart's |
| 101 | + own default would be `latest`. |
| 102 | +- **Config is re-rendered on every deploy**, reaching the pod as a mounted ConfigMap (e.g. at |
| 103 | + `/etc/frontier/configs/config.yaml`) that the binary is pointed at with `-c`. Individual keys can |
| 104 | + also be overridden by env vars using the `FRONTIER_SERVICE_` prefix (`config/config.go`). |
| 105 | + |
| 106 | +Chart `raystack/frontier` from `https://raystack.github.io/charts/` (pin a chart version), release |
| 107 | +name `frontier`, in the target namespace. |
| 108 | + |
| 109 | +**Steps:** run the deploy pipeline for the target environment (overriding the tag only to pin |
| 110 | +something other than the environment's configured version), watch the `helm upgrade`, then |
| 111 | +[verify](#5-verify-a-deployment). |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +## 3. Configure an environment |
| 116 | + |
| 117 | +### 3.1 Change an existing setting |
| 118 | + |
| 119 | +Console settings live in the environment's Frontier config → the `ui:` block — not in the Helm |
| 120 | +values. |
| 121 | + |
| 122 | +1. Edit the `ui:` block and merge it. |
| 123 | +2. Redeploy the **same** image version. No rebuild — config is read at runtime. |
| 124 | + |
| 125 | +Available settings (`UIConfig`, `pkg/server/config.go`): |
| 126 | + |
| 127 | +```yaml |
| 128 | +ui: |
| 129 | + port: 8100 |
| 130 | + title: "Frontier Admin" |
| 131 | + logo: "data:image/png;base64,…" |
| 132 | + app_url: app.example.com # per environment |
| 133 | + token_product_id: "" # product id used when adding credits |
| 134 | + organization_types: [] # industry list shown in the org form |
| 135 | + webhooks: |
| 136 | + enable_delete: false |
| 137 | + terminology: # optional per-entity rename; no server-side defaults |
| 138 | + app_name: "" # serialized to JSON as appName |
| 139 | + organization: { singular: "", plural: "" } # likewise project, team, member, user |
| 140 | +``` |
| 141 | +
|
| 142 | +Everything except `port` is returned by `GET /configs` (`UIConfigApiResponse`, |
| 143 | +`pkg/server/server.go`). Most keys are also documented inline in |
| 144 | +[`config/sample.config.yaml`](https://github.com/raystack/frontier/blob/main/config/sample.config.yaml), |
| 145 | +but that file lags the code — `webhooks` and `terminology.app_name` are missing from it — so `UIConfig` |
| 146 | +is the authority. A key on `main` may not exist in an older tag. |
| 147 | + |
| 148 | +### 3.2 Add a new setting |
| 149 | + |
| 150 | +A field the backend doesn't know about will not reach the SPA. Change the code upstream first: |
| 151 | + |
| 152 | +1. Add the field to `UIConfig` (`pkg/server/config.go`) and document it in the `ui:` block of |
| 153 | + `config/sample.config.yaml` — an undocumented key is invisible. |
| 154 | +2. Add it to `UIConfigApiResponse` and the `/configs` handler (`pkg/server/server.go`). |
| 155 | +3. Consume it in the SPA (`contexts/App.tsx` / the `Config` type). |
| 156 | +4. Test the whole path locally: put the value in `web/apps/admin/configs.dev.json` and run against a |
| 157 | + local backend (see the local-setup doc). Vite re-reads that file per request. |
| 158 | +5. Release upstream ([Cut a release](#7-cut-a-release-upstream-frontier)), set the value in the |
| 159 | + environment config, bump the environment's image version, and deploy. |
| 160 | + |
| 161 | +For dev-only values, `configs.dev.json` alone is enough — no backend change. |
| 162 | + |
| 163 | +--- |
| 164 | + |
| 165 | +## 4. Admin login (bootstrap superuser) |
| 166 | + |
| 167 | +A superuser service account seeded from config at boot, so automation always has a way in. |
| 168 | +**Requires image `v0.108.0`+** (`raystack/frontier` PR #1719). |
| 169 | + |
| 170 | +Wire it once per environment, with both values stored in the secrets backend: |
| 171 | + |
| 172 | +```yaml |
| 173 | +app: |
| 174 | + admin: |
| 175 | + bootstrap: |
| 176 | + client_id: "<from secrets backend>" # a UUID |
| 177 | + client_secret: "<from secrets backend>" |
| 178 | +``` |
| 179 | + |
| 180 | +Log in with `Authorization: Basic base64(client_id:client_secret)`. |
| 181 | + |
| 182 | +Behaviour (`internal/bootstrap/bootstrapuser.go`): |
| 183 | + |
| 184 | +- Re-seeded on **every** boot — idempotent, so redeploys never cause a lockout. |
| 185 | +- Rotate by changing `client_secret` and redeploying. **Never change `client_id`** — it's the |
| 186 | + service-account credential id. |
| 187 | +- Setting only one field is a hard boot failure (`client_id and client_secret must be set |
| 188 | + together`). Emptying **both** disables seeding — and since granting superuser requires a |
| 189 | + superuser, none can then be created via the API. |
| 190 | +- If the `client_id` already belongs to another principal, boot fails loudly rather than rotating |
| 191 | + the wrong account. |
| 192 | + |
| 193 | +The `app.admin.bootstrap` block in |
| 194 | +[`config/sample.config.yaml`](https://github.com/raystack/frontier/blob/main/config/sample.config.yaml) |
| 195 | +documents the UUID requirement, `uuidgen`, rotation, and the cost of disabling it. |
| 196 | + |
| 197 | +--- |
| 198 | + |
| 199 | +## 5. Verify a deployment |
| 200 | + |
| 201 | +If the hosts are behind an internal load balancer, connect to the VPN first. |
| 202 | + |
| 203 | +1. **Liveness** |
| 204 | + |
| 205 | + ```bash |
| 206 | + curl http://<connect-host>/ping |
| 207 | + # → {"status":"SERVING"} |
| 208 | + ``` |
| 209 | + |
| 210 | +2. **gRPC health** |
| 211 | + |
| 212 | + ```bash |
| 213 | + curl -X POST http://<connect-host>/grpc.health.v1.Health/Check \ |
| 214 | + -H 'Content-Type: application/json' \ |
| 215 | + -d '{"service":"raystack.frontier.v1beta1.AdminService"}' |
| 216 | + # also valid: raystack.frontier.v1beta1.FrontierService |
| 217 | + ``` |
| 218 | + |
| 219 | +3. **Configuration** — the real test that the right env config was applied: |
| 220 | + |
| 221 | + ```bash |
| 222 | + curl http://<admin-host>/configs |
| 223 | + # → this environment's title, app_url, terminology, organization_types |
| 224 | + ``` |
| 225 | + |
| 226 | +4. **SPA** — open `http://<admin-host>/` and log in. |
| 227 | + |
| 228 | +5. **Version** — no HTTP endpoint exposes it. The running image is most reliable: |
| 229 | + |
| 230 | + ```bash |
| 231 | + kubectl -n <namespace> get deploy -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.template.spec.containers[*].image}{"\n"}{end}' |
| 232 | + ``` |
| 233 | + |
| 234 | + Alternatives: the startup log line `frontier starting version=<tag>`, or `frontier version` in |
| 235 | + the pod. A mutable tag is a moving target. |
| 236 | + |
| 237 | +--- |
| 238 | + |
| 239 | +## 6. Roll back |
| 240 | + |
| 241 | +**Rollback = redeploy the previous image version.** Versioned tags are immutable and the SPA is |
| 242 | +embedded, so backend and console roll back together. |
| 243 | + |
| 244 | +1. Deploy with the tag set explicitly to the last known-good `vX.Y.Z`. |
| 245 | +2. Update the environment's pinned image version to match, so the next deploy doesn't roll forward |
| 246 | + again. |
| 247 | +3. [Verify](#5-verify-a-deployment). |
| 248 | + |
| 249 | +**Caveats** |
| 250 | + |
| 251 | +- An environment tracking a **mutable tag** has no previous version to return to — roll it back by |
| 252 | + pinning a real `vX.Y.Z`. |
| 253 | +- The bootstrap superuser is re-seeded on boot, so rollback never causes a lockout — but going below |
| 254 | + `v0.108.0` removes the feature and breaks anything that authenticates with it. |
| 255 | +- **If only config was wrong, don't roll the image back** — fix the `ui:` block and redeploy the |
| 256 | + same version ([§3.1](#31-change-an-existing-setting)). |
| 257 | + |
| 258 | +--- |
| 259 | + |
| 260 | +## 7. Cut a release (upstream `frontier`) |
| 261 | + |
| 262 | +Only for shipping backend or console code, and only in `raystack/frontier`. The versioned image |
| 263 | +published to `docker.io/raystack/frontier` is the sole artifact a deployment consumes. |
| 264 | + |
| 265 | +Push a tag matching `v*.*.*` (or dispatch `release.yml`). The release pipeline builds the SPA |
| 266 | +(`make admin-app` → `dist/admin`), embeds it into the Go binary with version ldflags, and publishes |
| 267 | +`{tag}`, `latest`, and `{tag}-amd64` for linux/amd64, plus `{tag}-arm64` from a second job. There's no |
| 268 | +combined manifest list, so arm64 must be pulled by its own tag. Then bump the target environment's |
| 269 | +image version and [deploy](#2-deploy-to-an-environment). |
| 270 | + |
| 271 | +> **Test console changes locally before tagging** — a release is the only route into an environment, |
| 272 | +> so a bad build costs a full cycle. |
| 273 | + |
| 274 | +> **Building locally?** `dist/admin` must exist before `go build` or the binary ships without a UI — |
| 275 | +> run `make admin-app` first. `Dockerfile.dev` reproduces the full embed in one multi-stage build. |
| 276 | +> The npm SDK in `web/sdk` ships separately via `web-sdk.yml`. |
| 277 | + |
| 278 | +--- |
| 279 | + |
| 280 | +## 8. Gotchas |
| 281 | + |
| 282 | +| Symptom | Cause / fix | |
| 283 | +|---|---| |
| 284 | +| API works but no UI; log says `ui server disabled: no port specified` | `ui.port` is `0` or unset — set it in the environment config and redeploy. | |
| 285 | +| API works but no UI; log says `failed to load ui` | Binary built without `dist/admin`. Rebuild via the release pipeline, or `make admin-app` before `go build`. | |
| 286 | +| SPA loads but shows wrong title/terminology | Wrong or stale env config. Check `GET /configs`, fix the `ui:` block, redeploy the same image. | |
| 287 | +| New config field never appears in `/configs` | Field exists only in YAML, not in code — complete every step in [§3.2](#32-add-a-new-setting). | |
| 288 | +| Deployed version isn't what the values file says | Expected — the deploy-time tag always overrides it ([§2](#2-deploy-to-an-environment)). | |
| 289 | +| "Rolled back" a mutable tag but nothing changed | Mutable tags have no previous version — pin an explicit `vX.Y.Z`. | |
| 290 | +| Boot fails or superuser login fails | Bootstrap misconfigured: fields set without a redeploy, only one of the two fields populated, `client_id` colliding with another principal, or image older than `v0.108.0` ([§4](#4-admin-login-bootstrap-superuser)). | |
| 291 | +| Browser API calls fail | The SPA proxies `/frontier-connect/` to `{app.host}:{app.connect.port}` inside the pod. Confirm the ingress routes the admin host to the UI port and the connect host to the Connect port. | |
0 commit comments