Resource Model
The resource chain
Section titled “The resource chain”Every deployment of this project is built from the same four layers, in this order:
GatewayClass → CloudflareGatewayConfiguration → Gateway → RoutesGatewayClassnames this project as its controller and, for Tunnel Mode, points at aCloudflareGatewayConfiguration.CloudflareGatewayConfigurationis a cluster-scoped object holding your Cloudflare account ID, credential Secret reference, allowed zones, and mode (tunnelordns). It’s cluster-scoped deliberately: it carries credentials and tenancy boundaries, so it must not be forgeable by creating a namespaced object in a namespace you don’t control.Gatewayis the standard Gateway API object — one listener set, resolved against exactly oneCloudflareGatewayConfiguration.- Routes (
HTTPRoute,GRPCRoute,TLSRoute, and so on) attach to aGatewayand carry your actual routing rules, same as any other Gateway API implementation.
How the middle link — CloudflareGatewayConfiguration to Gateway — resolves depends on mode:
Tunnel Mode resolves configuration through GatewayClass.spec.parametersRef, pointing at the
CloudflareGatewayConfiguration that class uses. This project owns the Tunnel-mode
GatewayClass outright, so it’s free to give that standard extension field this meaning.
Every Gateway under that class inherits the same configuration, through the class it
belongs to.
DNS Mode can’t use GatewayClass.parametersRef the same way, because the DNS-mode
GatewayClass is owned by the companion Envoy Gateway installation, not by this project —
and Envoy Gateway validates that field against its own EnvoyProxy type, rejecting anything
else. Instead, CloudflareGatewayConfiguration carries its own spec.targetRefs, resolved
entirely by this project’s own controller without touching any field Envoy Gateway inspects.
A targetRefs entry can name a Gateway directly (kind: Gateway), attaching to exactly
that one Gateway, or a GatewayClass (kind: GatewayClass), acting as a class-wide default
for every Gateway under it. A direct match always wins over a class-wide default. A DNS-mode
Gateway matched by neither is always an error — there’s no implicit fallback configuration.
User-authored versus auto-generated kinds
Section titled “User-authored versus auto-generated kinds”You author GatewayClass, CloudflareGatewayConfiguration, Gateway, Routes, and this
project’s policy CRDs (CloudflareTunnelPolicy, CloudflareAccessPolicy, and the other
CloudflareAccess* identity/access objects) yourself. Four further kinds exist, and the
controller normally generates and owns them as it reconciles what you did author — with two
exceptions where you can also create one directly:
CloudflareTunnel— normally auto-provisioned the first time a Tunnel-modeGatewayneeds one. Exception: you can create one directly yourself and bind a Gateway to it for tunnel sharing — the controller then reconciles ingress against it without ever taking ownership of it.CloudflareDNSRecord— normally one per hostname your Gateway/Routes resolve to, in both modes: a CNAME to the tunnel in Tunnel Mode, or the load-balancer address Envoy Gateway assigned in DNS Mode. Exception: you can also create one directly yourself for a standalone record not tied to any Gateway — an orthogonalTXTorMXrecord, or a routing record you want to reserve a hostname with ahead of a Gateway/Route. Both kinds of author compete for the same hostname through one shared, oldest-wins index, so a directly-created routing record and a Gateway/Route’s own claim on the same hostname can conflict.CloudflareGatewayStatus— DNS Mode only, one per DNS-modeGateway, with no supported user-creation path. It exists because Envoy Gateway, not this project, owns that Gateway’s ownstatus; see Status and Conditions for why this project’s readiness signal has to live somewhere else.CloudflareAccessApplication— with no supported user-creation path, produced when aCloudflareAccessPolicywins a hostname’s Access claim, carrying the resolved Cloudflare Access application configuration for that hostname.
If you find one of these four kinds in your cluster that you didn’t create yourself, that’s
expected — it’s a byproduct of a Gateway or policy you did author, not a separate thing to
manage on its own.
Where generated objects are placed
Section titled “Where generated objects are placed”Every one of those four generated kinds is created in the same namespace as the Gateway
that owns it (or, for CloudflareAccessApplication, the oldest accepted parent Gateway
among the winning policy’s targetRefs) — never the namespace of whichever Route happened to
trigger its creation. This isn’t
a style choice: a Kubernetes owner reference can’t cross namespaces, and a Route can attach to
a Gateway in a different namespace than its own (cross-namespace routing is a standard
Gateway API feature). Since a generated object has to be owned by something in its own
namespace to get cascade-deletion for free, and the Gateway (or a CloudflareTunnel riding
on it) is the only thing in the chain guaranteed to share a namespace with what it owns, that
Gateway’s namespace is where everything it generates lands.
CloudflareGatewayConfiguration is the one exception, and it’s cluster-scoped rather than
namespaced at all — by design, so that its credentials and zone allowlist aren’t reachable
just by creating a namespaced object somewhere.
Tunnel sharing
Section titled “Tunnel sharing”By default, a Tunnel-mode Gateway gets its own exclusively-owned tunnel — a 1:1 relationship
with no configuration needed. To share one tunnel across multiple Gateways instead, set
Gateway.spec.infrastructure.parametersRef to {kind: CloudflareTunnel, name: <existing tunnel's name>}. This is a standard Gateway API extension field, and Kubernetes doesn’t let
it carry a namespace of its own, so the tunnel it names is always in the referencing Gateway’s
own namespace.
Binding to an existing tunnel this way never takes ownership of it — the tunnel keeps whichever owner it already had (or no owner, if you created it directly). Sharing is always explicit and opt-in; nothing shares a tunnel implicitly just because two Gateways happen to be related.
The resource graph
Section titled “The resource graph”The top group (GatewayClass, CloudflareGatewayConfiguration, Gateway, Routes,
CloudflareAccessPolicy) is everything you author. The bottom group is everything the
controller generates from it: one CloudflareTunnel per Tunnel-mode Gateway (unless shared),
one CloudflareDNSRecord per resolved hostname — owned by the CloudflareTunnel in Tunnel
Mode, or by the Gateway itself in DNS Mode, since ownership can’t cross namespaces and each
mode’s generated record shares a namespace with a different owner (see Where generated
objects are placed above) — one CloudflareGatewayStatus
per DNS-mode Gateway, and one CloudflareAccessApplication per hostname a
CloudflareAccessPolicy actually wins, owned by the oldest accepted parent Gateway among that
policy’s winning targetRefs (a CloudflareAccessPolicy can target a Route or a Gateway
directly).
Lifecycle and Ownership covers what happens to these generated objects on deletion, and how this project decides it’s safe to touch a Cloudflare resource it didn’t create.