CoursesCrossplaneIntermediate

XRDs & self-service claims

Publish a platform API developers claim.

Advanced14 min · lesson 6 of 12

A Composite Resource Definition (XRD) defines the API for your composite — its name, its fields, and their schema and validation. Publishing an XRD does two things: it creates the composite type (the XR the platform team manages), and optionally a claim type — a namespaced, simplified resource that developers create in their own namespace. The claim is the self-service front door; the XR and composition are the machinery behind it.

SELF-SERVICE: CLAIM TO MACHINERY
1Developer claim
PostgresInstance in own namespace, size:small
2XRD
defines the API + validates the schema
3Composite (XR)
XPostgresInstance, platform-managed
4Composition
builds encrypted, backed-up MRs
The XRD publishes both types; devs touch only the claim, the platform owns the rest.
xrd.yaml
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata: { name: xpostgresinstances.acme.io }
spec:
group: acme.io
names: { kind: XPostgresInstance, plural: xpostgresinstances }
claimNames: { kind: PostgresInstance, plural: postgresinstances } # dev-facing
versions:
- name: v1alpha1
served: true
schema:
openAPIV3Schema:
properties:
spec:
properties:
size: { type: string, enum: [small, large] } # the only knob devs get

Self-service, safely

Now a developer provisions a production-grade database with a tiny, validated manifest — they pick size, and the composition supplies the encrypted, backed-up, correctly-networked reality. The platform team controls what fields exist (the XRD schema) and how they are fulfilled (the composition), so self-service does not mean a free-for-all: developers can only ask for what the API allows, and it is always built your way.

claim.yaml
# what a developer writes, in their own namespace
apiVersion: acme.io/v1alpha1
kind: PostgresInstance
metadata: { name: orders-db, namespace: team-orders }
spec:
size: small
writeConnectionSecretToRef: { name: orders-db-conn }
The XRD schema is your guardrail — constrain it
Whatever fields you expose on the claim are what developers can set, so constrain them tightly with enums, patterns, and required fields. Do not surface raw, dangerous knobs (public networking, arbitrary instance types) on a self-service claim; expose a small, safe vocabulary and let the composition make the risky decisions correctly. A loose XRD undermines the whole point of platform-mediated self-service.