Adds a minimal SSR-only Leptos dashboard to the operator, gated by a new `web-frontend` cargo feature. The whole frontend (HTML + Tailwind CSS) is bundled into the binary via `include_str!`, no cargo-leptos / WASM / hydration involved — air-gap clean, single container. build.rs invokes the standalone tailwindcss v4 CLI when the feature is on. Default builds are untouched. Static skeleton only — no interactivity yet. Kept as a comparison baseline for the Maud + HTMX variant on the next branch.
60 lines
2.3 KiB
Markdown
60 lines
2.3 KiB
Markdown
# harmony-fleet-operator
|
|
|
|
IoT operator — reconciles `Deployment` CRDs into NATS KV desired-state and
|
|
aggregates device/deployment state back into CR status.
|
|
|
|
## Web frontend (optional)
|
|
|
|
A small server-side Leptos dashboard is built into the operator behind the
|
|
`web-frontend` cargo feature. When the feature is enabled the operator's
|
|
`run` loop also serves an HTML dashboard on `0.0.0.0:18080`.
|
|
|
|
### Why it's bundled
|
|
|
|
The operator already ships as a single container. Splitting the dashboard
|
|
into a separate crate, container, and deployment would buy nothing and
|
|
cost an extra moving part to operate. Keeping it in-process means:
|
|
|
|
- **One binary, one container.** The compiled Tailwind CSS is embedded
|
|
via `include_str!`; there is no `pkg/` dir, no static-asset volume, no
|
|
CDN. Air-gapped clusters get the dashboard for free.
|
|
- **No JavaScript build toolchain.** Pure SSR via
|
|
`view! { … }.to_html()` — no `cargo-leptos`, no `wasm-bindgen`, no
|
|
hydration scripts. `cargo build` is the whole build.
|
|
- **Direct access to operator state.** The dashboard is in the same
|
|
process as the reconcilers; it can read fleet aggregator state without
|
|
a network hop or an extra API surface.
|
|
|
|
The trade-off: no client-side reactivity yet. Good enough for a
|
|
dashboard of aggregated numbers; we'll revisit if/when we need
|
|
interactive views.
|
|
|
|
### Running it locally
|
|
|
|
The standalone Tailwind v4 CLI must be on `PATH` at build time (the
|
|
`build.rs` invokes it to produce the CSS that's bundled into the
|
|
binary). Single static binary, no Node required:
|
|
|
|
```sh
|
|
# Linux x86_64 — pick the matching asset for other platforms from
|
|
# https://github.com/tailwindlabs/tailwindcss/releases
|
|
curl -L -o ~/.local/bin/tailwindcss \
|
|
https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64
|
|
chmod +x ~/.local/bin/tailwindcss
|
|
```
|
|
|
|
Then run the operator with the feature on. The operator also needs a
|
|
reachable NATS — the e2e demo brings one up; `nats-server -js` works for
|
|
a quick poke too:
|
|
|
|
```sh
|
|
cargo run -p harmony-fleet-operator --features web-frontend
|
|
```
|
|
|
|
Open <http://localhost:18080>.
|
|
|
|
The frontend lives in `src/frontend/` (`app.rs` for the Leptos
|
|
components, `server.rs` for the axum wiring). Everything in that
|
|
directory is `#[cfg(feature = "web-frontend")]`-gated; default builds
|
|
are unaffected.
|