Skip to main content

Modules and composition

Processes​

ComponentWhat it is
API serverGo, a single static binary. Serves the REST API under /v1, answers the authorization checks of the workers' gateways over their agents' links, holds the links to the workers' agents, and runs the reconciler and background jobs.
AgentGo, a single static binary, in each worker's cluster. Dials the control plane and drives its cluster. The only component that speaks to Kubernetes.
FrontendVue 3 + TypeScript single-page application, served as static files by nginx. Its API types are generated from the backend's OpenAPI document.
PostgreSQLAll persistent state: users, templates, workspaces, volumes, settings, audit log.
ValkeyRefresh tokens, pending sign-ins, buffered activity timestamps, and a pub/sub channel that nudges other replicas.

The API server image has one entry point, idekube, with three commands:

CommandPurpose
idekube serveRun the API server.
idekube migrateBring the schema up to date and create the first administrator. Safe to run concurrently.
idekube openapiPrint the OpenAPI document.

Source layout​

backend/
cmd/idekube/ the API server; lists the modules compiled in
cmd/idekube-agent/ the agent of a worker
cmd/idekube-sidecar/ what runs next to every workspace
cmd/idekube-cli/ idk, the command-line client
client/ the Go client of the API and of the sidecar, which idk and the MCP server use
mcp/ the MCP server, served at /v1/mcp and by idk mcp serve
app/ assembles the modules into the server and runs it
core/ what modules build on: api, db, bus (Valkey), settings, authz,
reconcile, jobs, work, events, notice, ownership, security, ...
modules/ auth, user, team, worker, workspace, access, variable, storage,
template, notification, network, cluster, audit, job, mcp, system
plugins/ the plugins of this distribution, one package each
worker/ the contract's Go side: Driver, kinds, features, the registry of drivers
link/ the WebSocket link between an agent and the control plane
agent/ what an agent does with its link
kubernetes/ the Kubernetes driver and the manifests it applies
gateway/ Envoy's control plane, which asks the agent who may reach a workspace
sidecar/ the sidecar: what may change while a workspace runs
archtest/ tests of the module boundaries no linter states
tests/ the assembled server against PostgreSQL and Valkey
migrations/ the server's own SQL migrations (goose); each module has its own
gen/ generated protobuf code

AGENTS.md keeps the full map.

The stack: Huma on net/http for routes and the OpenAPI document, pgx with sqlc for queries, goose for migrations, valkey-go, coder/websocket for the link, and client-go in the agent only.

Modules​

The backend is the sum of its modules. A module owns its tables, queries, routes, runtime settings, permissions and background work, and declares them in a module.Module (core/module):

FieldContributes
NameIdentifier.
PluginSet for a plugin: its description, what it requires, and whether it agrees to turn off.
MigrationsThe module's own migrations, applied in the order of the modules.
RoutesRegisters the module's operations.
SettingsRuntime settings sections.
PermissionsThe permissions it checks; requiring or granting one no module declares fails assembly.
ConstraintsThe database constraints a client may break, each as the apierr error it answers with.
GrantsPermissions the module gives to each role.
ReconcilersReconcilers for the module's resources.
Setup, StopStart and end what it holds while the server runs, such as the links of agents.
JobsBackground job kinds, scheduled or enqueued.
ActionsThe actions it audits, such as workspace.stop. Each is published as an event of that type and listed for the audit log; recording one that is not declared fails.
EventsThe other events it publishes, such as workspace.running.
HandlersWhat the module does about events, each handler a job of its own. A handler of a type no module declares fails assembly.
NoticesWhat it has people told of, named <module>.*: each kind is about the events of one type, and says whom an event concerns, what its email says in each language and whether it is emailed unless someone says otherwise (core/notice). The notification module delivers them and names none of their modules; the UI words a kind among its module's messages, under notices.
PublicWhat it tells the UI before anyone signs in, under its name in /v1/meta while it runs; the API describes it by its Go type.
UsageWhat a team holds, counted against its quota, for example {"storage_mb": 2048}.
BillableWhat a team is charged for, by the hour; unset, what Usage counts.
ReleaseSchedules everything a team owns for deletion.
SuspendStops what a team runs, e.g. when it is out of credit.

Built-in modules:

ModuleRoutesSettingsBackground work
worker/v1/workers, /v1/workers/connectworkerlinks to agents, placement, worker.advance_epoch, worker.mark_offline, worker.prune_agents, worker.trim_logs
user/v1/users, /v1/roles, /v1/permissionsuser.collect_deleted, user.prune_tokens
team/v1/teamsteams, billingteam.meter, team.allowances, team.collect_deleted
auth/v1/authauthauth.prune_devices
template/v1/templates, /v1/template-language
workspace/v1/workspacesworkspacesworkspace reconciler, workspace.mark_volumes_used, workspace.mark_unreachable, workspace.give_up_starting
access/v1/workspaces/{id}/session, /v1/workspaces/{id}/tokenaccessanswers the gateways, access.sweep_idle
variable/v1/users/me/variables, /v1/workspaces/{id}/variableshands variables to the sidecars, as a workspace contribution
storage/v1/volumesvolume reconciler
notification/v1/notifications, /v1/announcementsnotificationtells people of events, notification.email, notification.prune
network/v1/workspaces/{id}/network, /v1/network/workersnetworka workspace's network policy, as a workspace contribution
cluster/v1/clustersclustercluster.watch; a node's gang, peers and keys, as workspace contributions
audit/v1/auditauditaudit.prune
job/v1/jobs, /v1/job-kinds
mcp/v1/mcpmcp
system/v1/settings, /v1/plugins, /v1/system, /v1/object-storage/checkplatform

The server itself owns the jobs, security, logging, plugins and object_storage settings sections and the jobs.prune and events.prune jobs, and serves /healthz, /readyz, /metrics, /v1/openapi.json and /v1/meta, which gathers what the modules tell. The order of the built-in list (modules.Builtin) matters where modules release what a user owns: workspaces go before their volumes.

Plugins​

Modules are compiled in. What the platform does by itself is a built-in module, always there; a plugin connects it to what an installation may not have, such as a Git host or an LMS. A plugin is a module with a Plugin description, built on the services of the built-in modules (modules.Platform) and listed in plugins.All; a distribution with other plugins is a copy of cmd/idekube/main.go that lists those. Plugins are turned on and off at runtime through the plugins settings section. While one is off its operations answer 404, its jobs do not run, events do not reach it and the platform skips its hooks.

Besides what any module contributes, a plugin hooks into the platform through:

  • events (core/events): every audit record, and the phases reconcilers observe, published in the transaction of the change to the handlers of the plugins that are on;
  • template fields (template.Field): typed top-level fields of the template language;
  • workspace contributions (workspace.Contribution): a say in creating a workspace and in what is asked of it, and a part in what its worker runs, what its sidecar serves, including steps that put files in place, and what describes it;
  • UI definitions (frontend/src/plugins): pages, sidebar entries, profile tabs and components in the slots the pages offer.

Writing a plugin describes each.

Start-up​

app.Assemble builds the modules, registers their settings sections, grants, ownership hooks and reconcilers, and lets each register its routes. It does no I/O, which is how idekube openapi describes the API without a database. idekube serve then:

  1. connects to PostgreSQL and Valkey and loads the settings;
  2. accepts the links of the workers' agents, each of which attaches its worker's driver;
  3. starts the background work: the bus listener, the periodic settings refresh, the job runner with its schedules, and one loop per reconciler;
  4. serves HTTP until it receives SIGTERM. It then fails /readyz and goes on serving for 5 seconds while load balancers notice; drains in-flight requests for up to 25 seconds while the job runner and the reconcilers claim nothing more and give what they run 15 seconds to finish before handing it back; has the modules end what they hold, such as the links of agents, which the work needed until then; and last stops listening to the bus. The chart gives the pod 45 seconds for this.

Rules that keep it correct​

  • Desired state lives in PostgreSQL; the cluster is reconciled to it. Request handlers change rows and never call the cluster. See Desired state and reconciliation.
  • The driver boundary is the protobuf contract. Nothing outside worker/ imports a Kubernetes client, and the API server links none: agents drive the clusters. See Workers, agents and the link.
  • One transaction per request. Every operation is registered with api.Register, which hands the handler a transaction that begins on its first statement and commits before the response is written, so a failed commit becomes an error response. Services take the transaction and never commit. Work that must follow a commit, such as notifying other replicas, is registered with tx.OnCommit.
  • Audit records share the transaction of the change they describe.
  • Quota checks lock the team row (Teams.Lock, then Teams.Admit), so concurrent requests cannot overspend. A change through the API locks the team, then reads what it changes locked. The lock order is team, a plugin's own rows, workspace, volume; a batch takes its items in one order.
  • Runtime settings, not environment variables, for anything an operator may change.
  • Jobs are idempotent: a job interrupted by a crash runs again on another replica.
  • Bus messages are hints. Every subscriber also converges by polling the database, so a lost message only costs latency.