Skip to content

Resource Model

Every deployment of this project is built from the same four layers, in this order:

GatewayClass → CloudflareGatewayConfiguration → Gateway → Routes
  • GatewayClass names this project as its controller and, for Tunnel Mode, points at a CloudflareGatewayConfiguration.
  • CloudflareGatewayConfiguration is a cluster-scoped object holding your Cloudflare account ID, credential Secret reference, allowed zones, and mode (tunnel or dns). 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.
  • Gateway is the standard Gateway API object — one listener set, resolved against exactly one CloudflareGatewayConfiguration.
  • Routes (HTTPRoute, GRPCRoute, TLSRoute, and so on) attach to a Gateway and 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.

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-mode Gateway needs 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 orthogonal TXT or MX record, 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-mode Gateway, with no supported user-creation path. It exists because Envoy Gateway, not this project, owns that Gateway’s own status; 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 a CloudflareAccessPolicy wins 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.

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.

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.

Resource relationship diagram: GatewayClass connects to CloudflareGatewayConfiguration via parametersRef in Tunnel Mode; CloudflareGatewayConfiguration connects to Gateway via targetRefs naming a Gateway directly, or to GatewayClass via targetRefs as a class-wide default, in DNS Mode; Gateway connects to Routes via parentRefs; Gateway auto-generates and owns CloudflareTunnel and, in DNS Mode, CloudflareDNSRecord and CloudflareGatewayStatus; CloudflareTunnel auto-generates and owns CloudflareDNSRecord in Tunnel Mode instead; a CloudflareAccessPolicy holds targetRefs pointing at Routes or directly at a Gateway, and auto-generates a CloudflareAccessApplication owned by the oldest accepted parent Gateway among the targetRefs that won the hostname claim.

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.