Repository navigation
Add WorkspaceSeed and SystemWorkspace: backend services in every tenant workspace - #1090
Merged
Merged
Conversation
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.
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.
Contributor
Author
|
/approve |
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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:Bound, server-side applies each object under the field managerrailgrid-workspace-seed. An object withwhenBoundwaits 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.tenantAdminRulesreads it from the binding's annotation. A binding without the annotation gives full access, so provider bindings behave as before.What is refused
railgrid, or two bindings of one namesecretsorconfigmapswithout a selectorapis.kcp.io,tenancy.kcp.io,core.kcp.io, admission registration or apiextensions groupsapiVersion,kindormetadata.nameA refused seed gets
Accepted=Falseand is applied nowhere.Things to know when reviewing
WorkspaceSeedis platform administration: it decides what runs in every tenant workspace and which claims are accepted there, with no tenant consent. Only access toroot:railgrid:system:providersguards it.Full reference:
docs/workspace-seeds.md.Testing
make lintand the unit tests underpkg/hub/...andapis/...pass.TestZWorkspaceSeedin the provider e2e suite passes against embedded kcp: an existing workspace is bound and seeded, a label-Existsclaim 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.whenBoundobject appearing when its provider is enabled later, and a seed change reaching existing bindings.Second commit: SystemWorkspace and the admin UI
A seeded service needs a workspace of its own. Creating it as a
Providerputs it underroot:railgrid:providers, where the hub treats bindings of its exports as an enabled provider.SystemWorkspace(admin.railgrid.ai/v1alpha1) is theProviderobject's counterpart. Its reconciler provisionsroot:railgrid:system:<name>, a ServiceAccount that is always cluster-admin in that workspace, and a kubeconfig Secret (<name>-system-kubeconfig) inroot:railgrid:system:providers.system-service: no child workspaces, and no CatalogEntry export bound, so the service cannot register in the catalog.controllers,providersandtenantsare refused. A workspace the hub did not create (it checks an annotation and the type) is neither provisioned into nor deleted.system-workspaces(list, create, delete, kubeconfig, rotate) andworkspace-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 deletedoes not check.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 underpkg,apis,config, portalvue-tscandnpm testpass.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.--admin-users.kcp-initwith a system-service kubeconfig.