Type: Explanation · Audience: Anyone seeking understanding
This page provides a high-level overview of the components that make up the RezusCloud management plane. For the architecture behind these components, see Architecture.
Overview
RezusCloud is a single binary (rezuscloud) that runs as the management plane —
a long-running server that declares Kubernetes clusters (tenants), realises them
on infrastructure via OpenTofu, and surfaces their state read-only. A second
binary (rezusctl) is the CLI client.
classDiagram
direction TB
class HTTPAPI {
+REST api/v1 · K8s resource model
+optimistic concurrency
+watch_SSE()
}
class WebUI {
+templ + HTMX + Alpine
+read-only surfacing
+actions()
+live_SSE()
}
class Store {
+SQLite rezuscloud.db
+tenants · nodegroups · machines
+tfstate blobs · users · audit · secrets
+mutate() fans out via MultiBus
}
class EventBus {
+NATS embedded in-process
+subject per resource type
+publish()
+subscribe()
}
class ApplyQueue {
+debounced per tenant
+serial within · parallel across
+phase queued→applying→applied
+listener fan-out
}
class Applier {
+render .tf.json + tfvars
+pre-apply upgrade hook
+tofu init · apply · destroy
}
class Registry {
+oci · openstack · metal
+render_by_class()
}
class UpgradeEngine {
+rolling · one machine at a time
+health check + rollback
+runs persisted in store
}
class TFExec {
+tofu subprocess
+per-tenant workdir
+state_pull()
}
class TFBackend {
+serves /tfstate
+one encrypted blob per tenant
+shares the SQLite DB
}
class Projection {
+TF state → resource index
+extractor per kind
+machines · bindings
}
class Enricher {
+merge projected machines
+spec refresh only
}
class StatusTracker {
+phase → status writes
+never re-enqueues
}
class SecretsCache {
+Talos PKI bundles
+refresh on applied
}
class StatusGatherer {
+on-demand probe · 15 s TTL
+control-plane first
}
class MgmtLink {
+SideroLink-compatible WG
+per-node /64 from ULA
+pull-model config delivery
}
class Cloud {
+cloud provider APIs
+bare-metal machines
}
class Node {
+Talos node
}
HTTPAPI --> Store : CRUD — spec + status
WebUI --> Store : reads + actions
Store --> EventBus : spec mutations → watch adapter
Store --> ApplyQueue : spec mutations → EnqueueBus
HTTPAPI ..> EventBus : subscribe — watch/SSE
WebUI ..> EventBus : subscribe — live updates
ApplyQueue --> Applier : debounce elapsed
Applier --> UpgradeEngine : pre-apply hook
Applier --> Registry : render per provider class
Applier --> TFExec : exec in workdir
Registry --> Cloud : registry provider API calls
TFExec --> TFBackend : state via /tfstate (loopback)
TFBackend --> Store : blobs in shared DB
TFExec --> Projection : StatePull source
ApplyQueue --> StatusTracker : phase transitions
ApplyQueue --> Projection : rebuild on applied
ApplyQueue --> Enricher : merge on applied
ApplyQueue --> SecretsCache : refresh on applied
Enricher --> Projection : reads index
Enricher --> Store : machine spec refresh
StatusTracker --> Store : status writes
SecretsCache --> Store : Talos bundles
StatusGatherer --> Store : machines + versions
StatusGatherer ..> SecretsCache : Talos client
StatusGatherer ..> Node : on-demand probe
UpgradeEngine ..> Node : upgrade + health (Talos API)
MgmtLink --> Store : rendered configs
MgmtLink ..> Node : WG tunnel — config pull
Cloud ..> Node : VM + user_data
API Layer
HTTP API (REST)
The primary interface for creating and managing tenants, node groups, machines,
and config patches. Follows the Kubernetes API model: every resource has
metadata, spec, and status fields. Supports optimistic concurrency
(resourceVersion), label-based selection, finalizer-controlled deletion, and
watch/SSE streaming.
- Code:
internal/api/
WebUI
A server-rendered web interface using templ + HTMX + Tailwind CSS. Provides the
same operations as the API (create clusters, add node groups, watch
reconciliation) plus read-only surfacing of lower-layer state (machine health,
logs via talosctl dmesg). Never duplicates kubectl — once a cluster is up,
the user downloads a kubeconfig and works with the lower layers directly.
- Code:
internal/web/
Reconciliation Layer
Apply Queue
A debounced, per-tenant queue that coalesces rapid spec changes into a single
tofu apply. When a user creates or updates a tenant or node group, the
store's MultiBus fans the mutation out to two destinations in parallel:
the NATS watch adapter (SSE consumers) and the EnqueueBus, which enqueues
the tenant. The queue debounces; the Applier renders .tf.json + tfvars
and runs tofu init + tofu apply. Status writes are filtered on the
EnqueueBus path, so reconciliation feedback can never re-enqueue itself.
On every phase transition the queue fans out to four listeners: the status
tracker (phase → store), the projection rebuild, the store enricher, and the
secrets-cache refresh. Serial within a tenant, parallel across tenants.
- Code:
internal/applyqueue/,internal/reconcile/
TF Execution Engine
Execs the tofu binary as a subprocess in per-tenant work directories. Handles
tofu init, tofu apply, tofu state pull, with the RezusCloud HTTP backend
as the remote state endpoint. State encryption is conditional on
REZUSCLOUD_STATE_PASSPHRASE (pbkdf2 + aes_gcm).
- Code:
internal/tfexec/
Providers
RezusCloud-side Go modules that generate the .tf.json configuration that tofu
applies. Each provider wraps a real Terraform registry provider (OCI, OpenStack)
or operates directly against the Talos API (Metal for bare metal). Providers
declare the mapping between TF resource types and RezusCloud resources, which the
projection index uses to extract machines from TF state.
- Code:
internal/provider/oci/,internal/provider/openstack/,internal/provider/metal/
State Projection
Reads the TF state JSON after each apply and projects it into an in-memory index.
Each provider declares which TF resource types map to which RezusCloud kinds
(e.g., oci_core_instance → Machine). The projection extracts management
addresses, provider IDs, shapes, and hostnames from the TF state attributes.
- Code:
internal/projection/
Store Enrichment
After each successful apply, the StoreEnricher merges the projected TF-state machines into the store. New cloud instances that don't exist in the store are created; existing machines get their spec fields (management address, provider ID, shape) refreshed. Management-plane status (stage, ready, connected) is never overwritten — it comes from observation.
- Code:
internal/reconcile/enricher.go
State Layer
Store (SQLite)
The management plane's own database. Stores tenants, node groups, machines,
config patches, providers, users, API tokens, audit logs, and the Talos secrets
bundles. SQLite is the v1 backend — the StoreAPI interface allows future
backends (PostgreSQL, etc.) without changing callers.
- Code:
internal/state/
TF HTTP Backend
RezusCloud implements the Terraform HTTP backend protocol. tofu reads and
writes state through RezusCloud's endpoint (/tfstate), so TF state is stored
in the management database alongside the management-plane data. One state blob
per tenant.
- Code:
internal/tfbackend/
Event Layer
Event Bus (NATS)
NATS, embedded in-process in the single-replica management plane, is the event primitive behind the watch surface: every spec mutation is published to a per-resource-type subject, and both the REST watch/SSE endpoint and the WebUI live view subscribe to it. Reconciliation triggers do not ride NATS — they flow over the parallel EnqueueBus wire, straight from the store to the apply queue (see above), so a NATS hiccup can never stall reconciliation.
- Code:
internal/watch/
Status Layer
Status Gatherer
Performs on-demand tenant health probes with a short in-memory TTL (15 seconds). No background scrapers — probes fire only when the health endpoint is hit. Probes control-plane machines first, falls back to workers, via the real Talos API.
- Code:
internal/status/
Rolling Upgrade Engine
Detects Talos version drift between the tenant spec and observed machines. When a
version bump occurs, the engine runs a rolling upgrade (one machine at a time via
the Talos API: upgrade → health check → rollback on failure) before tofu apply regenerates version-specific config.
- Code:
internal/upgrade/,internal/upgrade/talos/
Supporting Components
Auth (JWT + API Tokens)
Local authentication with JWT for browser sessions and API tokens for programmatic access. Role-based access control (admin, edit, view).
- Code:
internal/auth/
Audit Log
HTTP middleware that records every mutating request (method, path, user, timestamp) for compliance and debugging.
- Code:
internal/audit/
Credentials & Secrets
Auto-generates the Talos secrets bundle (cluster PKI) when a tenant is created. Caches the bundle in memory for the upgrade engine and status probe. Secrets live in the store, not in TF variables.
- Code:
internal/credentials/
Config Rendering
Generates Talos machine configuration using the talos Terraform provider's
talos_machine_configuration data source. Version-aware: the config is
generated for the specific Talos + Kubernetes version declared in the tenant spec.
- Code:
internal/configrender/,internal/talosconfig/
CLI Binary
rezusctl
A static binary with two modes:
-
Boot (
rezusctl boot) — standalone, no API server needed. Boots Talos on Docker or QEMU platforms for bare-metal provisioning. -
Client (
rezusctl get/create/apply/delete/describe) — thin client against the REST API. Verb-driven model likekubectl. -
Code:
cmd/rezusctl/
See Also
- Architecture — how the components fit together
- API Design — why the Kubernetes API model