Gunnar

nordisk/Skidbladnir

.nornir/talos-unfold.md

# talos-unfold — design

> **Class:** `design` · the bare-metal rebirth target (B5). Same split as the
> k8s-unfold target ([`k8s-unfold.md`](k8s-unfold.md)): a **sync machineconfig
> generator** in the lean core + an **async apid apply** behind the `talos`
> cargo feature. Downstream of the libvirt/PXE ISO boot. No `talosctl` shell.

## f0 — where it sits

`rebirth` (from scratch) = **libvirt/PXE boots `talos.iso`** (already real,
`unfold::libvirt::LibvirtTarget`) → **apply a machineconfig over apid** → bootstrap
etcd (control-plane) / join (worker) → node `Ready`. This module owns the second
step: turning a small spec into the machineconfig, and (feature-gated) pushing it.

`Target::Talos { endpoint, node }` (`unfold.rs`) names such a node.

## f1 — the sync generator (core, pure, tested)

`unfold::talos::MachineConfig` (`unfold.rs`) — pure data:
`kind` (`ControlPlane`/`Worker`) · `cluster_name` · `cluster_endpoint`
(`https://…:6443`) · `node_name` · `k8s_version` · `registry_mirrors`
(`(registry, mirror)` — e.g. this constellation's `registry.local:5000` →
`http://127.0.0.1:5000`) · `token`.

`MachineConfig::render()` emits deterministic Talos **v1alpha1** YAML
(mirrors sorted) — **no `serde_yaml` in the lean core**, so contract tests assert
exact bytes (`control_plane_machineconfig_exact_bytes`,
`worker_machineconfig_exact_bytes`). Builders: `control_plane(…)` / `worker(…)`
`.with_mirror(…)` `.with_k8s_version(…)`.

## f2 — the async apid apply (feature `talos`)

`talos = ["dep:tokio"]` — OFF by default, so the core builds sync/dep-free. With
it on, `impl Unfold for TalosTarget` bridges sync→async
(`Runtime::block_on(apply_apid())`). **DONE:** `apply_apid` is no longer a bail-with-TODO
seam — it renders the real machineconfig and does the real apid gRPC push:
`ApplyConfiguration` then `Bootstrap` on the first control-plane node, via the
hand-written prost/tonic client in [`talos_apid.rs`](../src/talos_apid.rs)
(`unfold.rs:914` `apply_apid`, `talos_apid.rs:166` `apply_configuration`,
`talos_apid.rs:194` `bootstrap`). It never fakes a provision. Without the feature,
`unfold()` bails asking for the feature (mirrors `terraform`). Remaining gap:
waiting for the node to report `Ready` post-bootstrap is not yet implemented.

## Status

`cargo test` (default): **115 lib + 11 integration**, sync, no `tokio`/gRPC.
`cargo build --features talos` + `cargo test --features talos`: green (2 `#[ignore]`
live tests). The machineconfig generator is real + byte-tested; the apid push
(`ApplyConfiguration`/`Bootstrap`) is real and implemented, not just a documented
seam. `talos_live_apply` (`#[cfg(feature="talos")] #[ignore]`) is for
real Talos hardware — the lab worker node
(`cargo test --features talos -- --ignored talos_live`).

**Follow-up:** the apid gRPC push is wired (`ApplyConfiguration` + `Bootstrap`);
remaining work is waiting for post-bootstrap `Ready` status so `rebirth` is
verifiably metal→running, not just metal→applied.