Multi-Tenancy
A single cluster can serve multiple tenants — different teams, different applications, or
different environments — through more than one CloudflareGatewayConfiguration. This page
covers the isolation boundaries that make sharing one cluster safe, and where those
boundaries stop.
One configuration per tenant is the recommended pattern, not a requirement
Section titled “One configuration per tenant is the recommended pattern, not a requirement”Nothing stops multiple Gateways or GatewayClasses across multiple namespaces from
referencing the same CloudflareGatewayConfiguration — that’s a deliberately supported case,
for teams that genuinely want to share one credential and one rate-limit budget. But every
object referencing a configuration inherits all of that configuration’s boundaries: its
zoneAllowlist, its credential, its rate-limit exposure. If you want tenants isolated from
each other rather than cooperating, give each tenant its own configuration — one credential,
one zone boundary, one namespace boundary, each independent of the others.
zoneAllowlist: defense in depth, not a substitute for token scoping
Section titled “zoneAllowlist: defense in depth, not a substitute for token scoping”zoneAllowlist restricts which Cloudflare zones a given configuration may act on. A hostname
outside the list is rejected at reconcile time, before any Cloudflare API call, with
Reason=InvalidZone — see InvalidZone. An empty or
unset zoneAllowlist is fail-closed: it allows no zone at all, not every zone — the
opposite of a permissiveness risk. (There’s no admission webhook in this project; this check
runs the first time the controller reconciles the object, not when kubectl apply is
accepted.)
This is an in-cluster boundary, enforced by this project’s own reconcile-time logic, not a
property of the underlying Cloudflare API token. If the token itself can reach a zone,
nothing about zoneAllowlist stops a differently configured object — one with a wider
allowlist — from reaching it too, because the actual permission lives at Cloudflare, on the
token. zoneAllowlist catches a misconfigured tenant before it can act outside its intended
boundary; it never widens or narrows what the credential itself can do. Scope the underlying
token narrowly as well — see Token Scopes — rather than relying on
zoneAllowlist alone.
namespaceSelector: which namespaces may use this configuration
Section titled “namespaceSelector: which namespaces may use this configuration”namespaceSelector restricts which namespaces may reference a CloudflareGatewayConfiguration
at all. Left unset, the default, any namespace may reference it — so a shared configuration
without a namespaceSelector is implicitly open to the whole cluster. An object in a namespace
the selector doesn’t match fails to resolve its configuration with the same
Reason=InvalidParameters it would get if the configuration didn’t exist at all — though the
message is specific about why: it names namespaceSelector as the cause rather than reusing
the “not found” wording.
A Gateway doesn’t carry a configurationRef field itself — it reaches its configuration
indirectly, through its GatewayClass’s spec.parametersRef. What gets checked against
namespaceSelector is the Gateway’s own namespace, not the GatewayClass’s (which is
cluster-scoped and has none). A CloudflareTunnel/CloudflareDNSRecord, by contrast, does
carry configurationRef directly, and it’s that object’s own namespace that’s checked.
Hostname uniqueness is cluster-wide, not per-tenant
Section titled “Hostname uniqueness is cluster-wide, not per-tenant”A hostname can only be claimed once across the entire cluster, regardless of which
configuration, namespace, or tenant is doing the claiming. The rule is first-writer-wins: the
oldest CreationTimestamp holds the hostname, and anything claiming the same hostname later
reports Reason=Conflicted — see Conflicted. Two tenants
with non-overlapping zoneAllowlists still can’t claim the same hostname twice; hostname
uniqueness isn’t scoped by tenant at all.
The configuration object itself, and RBAC
Section titled “The configuration object itself, and RBAC”CloudflareGatewayConfiguration is cluster-scoped — deliberately, so it can’t be forged by
creating a namespaced object in a namespace you don’t control. That also means Kubernetes RBAC
on this cluster-scoped kind (and the one other cluster-scoped kind, CloudflareAccessIdentityProvider)
is the actual tenant-isolation
mechanism for who may create or edit a configuration in the first place, with sharper teeth
than “privileged object” might suggest. See
RBAC: who should manage a CloudflareGatewayConfiguration
for the full detail — it isn’t repeated here.
Rate-limit isolation
Section titled “Rate-limit isolation”This isolation concern is about this project’s own reconcile-loop API call volume against
Cloudflare per credential — not end-user HTTP/DNS traffic volume, which never touches
Cloudflare’s per-token API rate limit at all. Each CloudflareGatewayConfiguration
authenticates with its own credential, and this project treats one credential as one
rate-limit budget: give two tenants two different tokens, and a busy reconcile loop on one
tenant’s objects shouldn’t exhaust the other’s budget. This is this project’s own conservative
working assumption, not a guarantee Cloudflare’s API documents: it has not been possible to
conclusively determine whether Cloudflare pools rate-limit budget across multiple tokens under
one account (only one credential was available to test), so whether budgets are actually
isolated per token remains unconfirmed either way. Treat separate credentials as the safer
default for tenants you actually want isolated from each other’s load, not as a verified hard
boundary.
Separately: Access applications have their own, unrelated cross-tenant exposure. An Access
application can be visible to, and deletable by, any cluster or session sharing the same
Cloudflare account, regardless of zoneAllowlist. The two-team example below shares one Cloudflare
account, so if either team uses Access applications, that exposure applies to them too — see
Access for the detail.
Example: two tenants on one cluster
Section titled “Example: two tenants on one cluster”Two teams, team-a and team-b, share one Cloudflare account but get their own zone, their
own credential, and their own set of namespaces allowed to use their configuration. Each
team’s namespace carries the label its configuration’s namespaceSelector requires, and each
team gets its own GatewayClass pointing at its own configuration via parametersRef — a
Gateway has no configurationRef field of its own, so it’s the GatewayClass it references
that determines which configuration applies:
apiVersion: v1kind: Namespacemetadata: name: team-a labels: team: team-a---apiVersion: v1kind: Namespacemetadata: name: team-b labels: team: team-b---apiVersion: cfgateway.dreamfuselabs.com/v1alpha1kind: CloudflareGatewayConfigurationmetadata: name: team-a-configspec: mode: tunnel accountID: "$ACCOUNT_ID" zoneAllowlist: ["team-a.example.com"] namespaceSelector: matchLabels: team: team-a credentialSecretRef: namespace: cloudflare-gateway-controller-system name: cloudflare-api-token-team-a key: api-token---apiVersion: gateway.networking.k8s.io/v1kind: GatewayClassmetadata: name: team-a-classspec: controllerName: cfgateway.dreamfuselabs.com/tunnel-controller parametersRef: group: cfgateway.dreamfuselabs.com kind: CloudflareGatewayConfiguration name: team-a-config---apiVersion: cfgateway.dreamfuselabs.com/v1alpha1kind: CloudflareGatewayConfigurationmetadata: name: team-b-configspec: mode: tunnel accountID: "$ACCOUNT_ID" zoneAllowlist: ["team-b.example.com"] namespaceSelector: matchLabels: team: team-b credentialSecretRef: namespace: cloudflare-gateway-controller-system name: cloudflare-api-token-team-b key: api-token---apiVersion: gateway.networking.k8s.io/v1kind: GatewayClassmetadata: name: team-b-classspec: controllerName: cfgateway.dreamfuselabs.com/tunnel-controller parametersRef: group: cfgateway.dreamfuselabs.com kind: CloudflareGatewayConfiguration name: team-b-configWith this layout: a Gateway in the team-a namespace referencing team-a-class resolves to
team-a-config — the Gateway’s own namespace is what’s checked against team-a-config’s
namespaceSelector, and it matches. That same Gateway couldn’t use team-b-class instead:
its namespace’s labels don’t match team-b-config’s namespaceSelector, so it would fail to
resolve with Reason=InvalidParameters. Even if it could, team-a-config’s zoneAllowlist
would reject any hostname outside team-a.example.com. And each team’s credential is its own,
so (under this project’s unconfirmed-but-conservative per-credential assumption above) a busy
reconcile loop against one team’s zone shouldn’t exhaust the other’s rate-limit budget — though
if either team adds Access applications, the account-wide Access exposure described above
still applies across both.
Credentials and Secrets walks through creating each tenant’s credential Secret and the RBAC around it in full.