7. Validation in the gateway and in admission webhooks
- Status: Accepted
- Date: 2026-05
Context
Resources reach the cluster in two ways: through the gateway API (the dashboard) and directly (kubectl, GitOps). Admission webhooks are the only control that covers both, but they need serving certificates, which means cert-manager, and an installation must not end up without them by accident.
Decision
Validation rules for the custom resources live in one package,
operator/api/v1alpha1/validation, used by the gateway before it writes and
by the admission webhooks. Admission webhooks for all four resources are the
cluster-wide guarantee. They are registered when the cert-manager.io/v1
API is served; any other discovery error is retried and then stops the
operator, so an API server hiccup at startup never silently disables them.
Webhooks skip metadata-only updates, so a resource that predates a rule can
always lose its finalizer.
Consequences
- Rules are written once. kubectl users and dashboard users get the same error messages for the rules both paths apply.
- The gateway applies the rules that concern what it writes (formats, namespaces, mounts, security contexts, test ports and TTLs). Existence checks, immutability and the check that a Team’s mount targets exist run only in the webhooks, so a cluster without cert-manager does not get them.