A CRD is a user interface
A developer-friendly CRD gives users a small, documented set of choices, rejects invalid requests at the API boundary, and reports progress in status. Design the resource around the outcome a team wants, then let the platform controller own implementation details.
The Kubernetes API server can validate custom resources against the CRD schema. That lets the platform catch misspelled fields, wrong types, and invalid values before the controller begins work. A schema is part of the developer experience because it shapes both errors and discoverability.
Name fields for intent
Prefer fields that describe a stable outcome such as service size, exposure mode, or a reference to an approved configuration. Avoid asking developers to select internal deployment tools, controller names, or low-level cloud details unless the platform explicitly supports that choice.
Keep related options grouped and use enums for finite choices. Make defaults visible in the documentation, even when the API server applies a default. Developers should be able to review a manifest and understand what they requested without consulting controller source code.
Validate before reconciliation
Use the OpenAPI schema to enforce types, required fields, numeric bounds, and enumerated values. Add a default when there is one clear platform choice. For a constraint that compares fields, CEL rules in the CRD can reject invalid combinations in the API server without an out-of-process validation webhook.
For example, if minReplicas and maxReplicas define an interval, the API should reject maxReplicas below minReplicas. Keep validation messages specific enough to identify the field and accepted rule. Do not encode policy that changes frequently in a rigid schema; route such policy through a versioned configuration or policy mechanism.
Report state developers can act on
Keep requested choices in spec and observations in status. Conditions can show whether reconciliation is progressing, ready, or blocked. Use a stable condition type and reason, and include concise details that help a developer fix their request.
Define the meaning of Ready before implementing the controller. If the environment needs a route, credentials binding, and a healthy workload, decide which of those states readiness requires. Keep transient details out of the API contract unless a consumer needs them.
Review a small API shape
This example shows the shape of a request, not a complete production CRD. The schema, access policy, controller and status updates still need implementation.
apiVersion: platform.example.com/v1alpha1
kind: ServiceEnvironment
metadata:
name: catalog-preview
namespace: team-catalog
spec:
size: small
exposure: internal
status:
conditions:
- type: Ready
status: "False"
reason: Provisioning
message: Waiting for the workload to become available.Avoid common schema traps
A field called config that accepts arbitrary nested data is hard to validate, document, or evolve. Define the small set of supported inputs explicitly.
Defaults that depend on an environment hidden from the user make the same manifest behave differently without explanation. Show the source of a default and report resolved values only when useful.
Status messages that expose internal endpoint names or raw errors can disclose implementation details. Translate failures into actionable reasons and keep sensitive diagnostics in protected logs.
A strict schema can make evolution harder if required fields have no migration path. Consider which defaults and optional fields will support older manifests before you make the API stable.
Use this review checklist
A short API review can catch friction before a controller ships. Ask a developer who did not write the CRD to explain a sample manifest and predict what happens after applying it.
- Can a developer request the outcome without choosing internal implementation details?
- Does the schema reject misspelled, unsupported, or contradictory inputs?
- Are defaults and allowed choices documented next to the API example?
- Does status distinguish progress, readiness, and a blocked request?
- Do error reasons point to a field or next action without exposing secrets?
- Can an older manifest still be interpreted after the next API update?
References & further reading
Need help with your Go backend?
I work with engineering teams on focused Go and Kubernetes platform engagements, with limited consulting availability.
Explore Go consulting services