Skip to main content

Module crd

Module crd 

Source
Expand description

R21 — CRD (CustomResourceDefinition) serving.

Lets operators register new typed kinds at runtime without recompiling. A CRD declares:

  • spec.group
  • spec.versions[] — each {name, served, storage, schema.openAPIV3Schema}
  • spec.scope (Namespaced | Cluster)
  • spec.names — {plural, singular, kind, listKind, shortNames[]}

§How it gets served (REUSE, not fork)

A CRD object is stored opaquely via the SAME StoreBackedHandler as any other kind (the apiextensions.k8s.io/v1.CustomResourceDefinition catalog row builds it automatically). The CrdController then reacts to CRD writes by registering a StoreBackedHandler PER SERVED VERSION into the apiserver’s live RouterState (via the DynamicHandlerSink trait the apiserver implements) — so every CR instance verb (CRUD / list / watch) flows through the existing catch-all + do_* bodies, and the group + resource auto-appear in discovery (both fold the same live handler snapshot). There is NO parallel CR codepath.

§Reconcile rule (CrdController)

For each CustomResourceDefinition in the store:

  1. Parse spec through the typed CrdSpec serde border.
  2. For EACH served version, sink.register_crd(...) under (group, version, plural) + scope + names + shortNames.
  3. Patch CRD status to Established=True / NamesAccepted=True.

Removal of a CRD object → sink.unregister_crd(...) for every version the controller had registered (precise GC via the private CrdEntry-keyed bookkeeping set). Orphaned CR objects remain in the store unreachable (no cascade-delete — finalizers are a future brick).

Structs§

CrdController
Controller that syncs apiextensions.k8s.io/v1.CustomResourceDefinition objects from the store into the apiserver’s live handler table via a DynamicHandlerSink. Driven by a WatchDriver filtered to ["CustomResourceDefinition"].
CrdEntry
One registered CRD-version handler descriptor — the controller’s PRIVATE bookkeeping of “what I registered” (keyed by (group, version, plural)) so unregister-on-delete is precise. This REPLACES the old CrdRegistry routing surface; routing now lives in the apiserver’s RouterState via the DynamicHandlerSink.
CrdHandlerSpec
The typed argument bundle for DynamicHandlerSink::register_crd — one served CRD version’s full handler shape, carried as owned Strings (the controller derives them from the typed CrdSpec).
CrdNames
spec.names — how kubectl names the custom resource.
CrdSpec
The typed spec of a CustomResourceDefinition — the parse border the controller drives. Unknown fields tolerated (no deny_unknown_fields).
CrdSubresources
spec.versions[].subresources — which subresources a CRD version serves.
CrdVersion
One entry in spec.versions[].

Enums§

CrdError
Registry errors.
CrdScope
Resource scope.

Traits§

DynamicHandlerSink
Typed sink the apiserver implements so the controller (which must NOT depend on engenho-apiserver — that would be a dependency cycle, since apiserver already depends on controllers for admission) can mutate the live RouterState handler table.

Functions§

serve_stored_crds
Register every served version of every CRD in store into sink, and return how many were registered.