Skip to content

Add WorkspaceSeed and SystemWorkspace: backend services in every tenant workspace - #1090

Merged
railgrid-prow[bot] merged 3 commits into
railgrid:mainfrom
mjudeikis:workspace-seeds
Nov 13, 2026
Merged

railgrid-prow[bot] merged 3 commits into
railgrid:mainfrom
mjudeikis:workspace-seeds

Conversation

@mjudeikis

@mjudeikis mjudeikis commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds WorkspaceSeed (admin.railgrid.ai/v1alpha1): a way for a platform service that is not a provider to reach every tenant workspace. A seed says two things: bind these exports, and create these objects.

The first user is Switchboard, the metered model gateway. Its seed is in that repository under deploy/railgrid/; no seed ships with the hub.

Why not a provider

A provider has a CatalogEntry, a place in the portal and an Enable step per workspace. Switchboard should be in every workspace from the start, show up nowhere in the catalog, and give the tenant one grant they can read and cannot delete and create again.

How it works

For every tenant workspace (root:railgrid:tenants:<org>:<workspace>) and every accepted seed, the hub:

  1. Creates each APIBinding with its own credential, with exactly the listed permission claims accepted, and annotates it with the seed's name and the tenant access.
  2. Once every binding of the seed is Bound, server-side applies each object under the field manager railgrid-workspace-seed. An object with whenBound waits until the exports it names are bound in that workspace, so an object of a provider's API appears where that provider is enabled.

It runs when an APIBinding in a workspace changes, when a seed changes, and when the hub's leader starts. There is no timer and the hub does not watch the seeded objects.

tenantAccess (ReadWrite, ReadOnly, None) on a seeded binding narrows the member role for the bound API groups. tenantAdminRules reads it from the binding's annotation. A binding without the annotation gives full access, so provider bindings behave as before.

What is refused

  • a binding named railgrid, or two bindings of one name
  • a claim on core secrets or configmaps without a selector
  • an object of the RBAC, apis.kcp.io, tenancy.kcp.io, core.kcp.io, admission registration or apiextensions groups
  • a manifest without apiVersion, kind or metadata.name

A refused seed gets Accepted=False and is applied nowhere.

Things to know when reviewing

  • Writing a WorkspaceSeed is platform administration: it decides what runs in every tenant workspace and which claims are accepted there, with no tenant consent. Only access to root:railgrid:system:providers guards it.
  • Nothing a seed created is ever removed, including when the seed is deleted.
  • Manifests are literal; there is no per-workspace templating.
  • Status is per seed. A workspace that fails to seed is only in the hub's log.

Full reference: docs/workspace-seeds.md.

Testing

  • make lint and the unit tests under pkg/hub/... and apis/... pass.
  • TestZWorkspaceSeed in the provider e2e suite passes against embedded kcp: an existing workspace is bound and seeded, a label-Exists claim on Secrets is enforced through the export's virtual workspace, the tenant reads the seeded object and is refused every write, an object gated on an unbound export is not created, and a seed claiming every Secret is refused.
  • Not run: the rest of the provider e2e suite.
  • Unit tests only: a workspace created after the seed, a whenBound object appearing when its provider is enabled later, and a seed change reaching existing bindings.
  • Not tested: the Switchboard seed against a real Railgrid install.

Second commit: SystemWorkspace and the admin UI

A seeded service needs a workspace of its own. Creating it as a Provider puts it under root:railgrid:providers, where the hub treats bindings of its exports as an enabled provider.

  • SystemWorkspace (admin.railgrid.ai/v1alpha1) is the Provider object's counterpart. Its reconciler provisions root:railgrid:system:<name>, a ServiceAccount that is always cluster-admin in that workspace, and a kubeconfig Secret (<name>-system-kubeconfig) in root:railgrid:system:providers.
  • New WorkspaceType system-service: no child workspaces, and no CatalogEntry export bound, so the service cannot register in the catalog.
  • Guards: controllers, providers and tenants are refused. A workspace the hub did not create (it checks an annotation and the type) is neither provisioned into nor deleted.
  • Admin API: system-workspaces (list, create, delete, kubeconfig, rotate) and workspace-seeds (list, create, replace, delete). Seeds are sent as YAML and validated before anything is stored. Deleting a system service is refused while a seed references its workspace; kubectl delete does not check.
  • Admin area: two sections, System services and Workspace seeds.

The new routes are registered ahead of the provider routes. On a subrouter gorilla/mux drops a method mismatch once a later route's prefix matches, which turned the provider rotate route's 405 into a 404 and failed TestRotateProviderCredentialIsPOSTOnly.

Testing of the second commit

  • make lint, Go unit tests under pkg, apis, config, portal vue-tsc and npm test pass.
  • TestYSystemWorkspace (new) passes against embedded kcp: provisioning, the credential creating an APIExport, no catalog API, no child workspaces, no reach outside its workspace, both refusals, and teardown.
  • The admin routes have unit tests against a fake client only; the e2e hub runs without --admin-users.
  • The two admin sections have not been exercised in a browser against a hub.
  • Not tested: credential rotation for a system service, a seed saved before its export exists, and Switchboard's kcp-init with a system-service kubeconfig.

A provider is something a tenant enables from the catalog. Some platform
services are neither visible nor optional: a metered model gateway should be
in every workspace, appear nowhere in the portal, and hand the tenant one
object they can read and not multiply.

WorkspaceSeed (admin.railgrid.ai/v1alpha1) declares the APIExports the hub
binds into every tenant workspace, with the permission claims it accepts, and
the objects it creates there once those bindings are Bound. An object can
wait for another export to be bound, so an object of a provider's API appears
where, and as soon as, that provider is enabled.

tenantAccess on a seeded binding narrows the member role for the bound groups
to read-only or nothing. The hub records it as an annotation on the APIBinding
and tenantAdminRules computes the role from it; without the annotation a
binding gives full access as before.

Seeds are validated before use: no binding named railgrid, no unscoped claim
on core secrets or configmaps, no objects of the RBAC, kcp, admission or
apiextensions groups. Nothing a seed created is removed when the seed changes
or is deleted.
@mjudeikis
mjudeikis requested a review from cwilhit as a code owner November 13, 2026 12:15
A service that reaches tenant workspaces through a WorkspaceSeed needs a
workspace of its own, and creating it as a Provider puts it under
root:railgrid:providers, where the hub treats bindings of its exports as an
enabled provider.

SystemWorkspace (admin.railgrid.ai/v1alpha1) is the Provider object's
counterpart for such services. Its reconciler provisions
root:railgrid:system:<name>, a ServiceAccount that is cluster-admin in that
workspace, and a kubeconfig Secret in root:railgrid:system:providers. The
workspace is of a new type, system-service, which binds no CatalogEntry
export, so the service cannot register in the catalog. The hub refuses its
own names (controllers, providers, tenants) and never provisions into or
deletes a workspace it did not create.

The admin area gets two sections. System services creates and deletes these
workspaces and downloads their kubeconfig. Workspace seeds lists seeds with
their Accepted condition and edits the spec as YAML; the hub validates on
save and stores nothing it would refuse. The admin API refuses to delete a
system service while a seed references its workspace.

The new admin routes are registered ahead of the provider routes: on a
subrouter gorilla/mux drops a method mismatch once a later route's prefix
matches, which turned the provider rotate route's 405 into a 404.
@mjudeikis mjudeikis changed the title Add WorkspaceSeed: backend functionality in every tenant workspace Add WorkspaceSeed and SystemWorkspace: backend services in every tenant workspace Nov 13, 2026
@mjudeikis

Copy link
Copy Markdown
Contributor Author

/approve

@railgrid-prow

railgrid-prow Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mjudeikis

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@railgrid-prow
railgrid-prow Bot merged commit f38a919 into railgrid:main Nov 13, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant