Cluster-scoped resources#
Resources are namespaced by default. Create a cluster-scoped kind with
genop create api <Kind> --scope Cluster (env API_SCOPE).
Declarative equivalent. Set
scope: Clusteron the resource in.genop.yaml, then rungenop apply:controllers: - name: network resources: - version: v1alpha1 kind: Region scope: Cluster
The scope key in .genop.yaml is only read when genop first scaffolds a resource:
the resource type and the generated e2e test are written once and never
rewritten, so editing scope on an already-scaffolded resource would
leave the CRD and the webhook rules disagreeing. To change a kind’s scope,
run genop delete api and then genop create api again; changing a CRD’s
scope is a breaking API change anyway.
genop emits +kubebuilder:resource:scope=Cluster on the type, sets
scope: Cluster on the webhook rules, and drops the namespace from the
generated e2e test.
Two things to know: events for a cluster-scoped object are recorded in the
default namespace, and a
cluster-scoped object can only be owned by other cluster-scoped objects, so
deletionPolicy: fromAncestor on a cluster-scoped kind only makes sense
with cluster-scoped ancestors. Resource metrics carry an empty namespace
label for cluster-scoped objects.