Quickstart — DNS Mode
Log in to GHCR with a token that has read:packages scope, piping the token on stdin rather than passing it as an argument (avoids it landing in shell history or the process list):
echo "<your-token>" | helm registry login ghcr.io --username <your-github-username> --password-stdinCreate a kubernetes.io/dockerconfigjson Secret from that same login, in the same namespace you install the chart into, and pass it through the chart's existingimagePullSecrets value:
kubectl create secret docker-registry your-pull-secret \ --docker-server=ghcr.io \ --docker-username=<your-github-username> \ --docker-password=<your-token> \ --namespace <your-release-namespace>imagePullSecrets: [{name: your-pull-secret}]or, as a Helm --set flag (quoted, since the brackets are otherwise a glob pattern in zsh): --set 'imagePullSecrets[0].name=your-pull-secret'.
Expose a Kubernetes Service through a standard public LoadBalancer and Envoy Gateway’s data
plane, with Cloudflare DNS records and Let’s Encrypt certificates managed automatically. This
walkthrough is runnable as written against a real Cloudflare account, a zone you control, and a
cluster with a working LoadBalancer implementation — a cloud provider’s, or MetalLB on
bare-metal/local clusters (see the callout below).
Prerequisites
Section titled “Prerequisites”-
A Kubernetes cluster, version 1.28 or later, with Gateway API v1.6.0’s standard CRDs installed:
Terminal window kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.6.0/standard-install.yaml -
cert-manager, tested against v1.21.3 (see Compatibility for the full tested-version matrix). Install this before the controller (below), not after:
Terminal window kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.21.3/cert-manager.yamlkubectl wait --for=condition=Available --timeout=120s deployment --all -n cert-managerOn GKE Autopilot specifically, this stock manifest fails permanently instead: it hardcodes
--leader-election-namespace=kube-system(plus matching RBAC) on the controller andcainjector, and Autopilot’s admission policy denies writes tokube-systemfor anything but Google-managed components, socainjectornever acquires its lease, never injects the webhook’s CA bundle, and every object creation through the webhook fails withx509: certificate signed by unknown authorityindefinitely. Fix it before applying: replace everykube-systemreference in the manifest withcert-managerfirst (e.g.curl -sSL <url> | sed 's/kube-system/cert-manager/g' | kubectl apply -f -).The controller checks once, at its own startup, whether cert-manager’s
CertificateCRD is registered on the cluster, and keeps that answer for its whole process lifetime — this is deliberate, since it’s what lets the controller start at all on a cluster with no cert-manager (Tunnel Mode has no such dependency). If you install cert-manager after the controller, it won’t notice until you restart it:Terminal window kubectl rollout restart deployment/cloudflare-gateway-controller \-n cloudflare-gateway-controller-system -
Envoy Gateway, a separate install this project does not manage (the companion pattern — DNS Mode’s
GatewayClassand data plane belong entirely to Envoy Gateway, not this controller), configured to recognize this controller’s Gateways:-
Gateway API v1.6.0’s standard CRDs (already applied above).
-
Envoy Gateway v1.8.2’s own CRDs, applied server-side (its
EnvoyProxyCRD alone exceedskubectl apply’s default client-side size limit):Terminal window kubectl apply --server-side -f https://github.com/envoyproxy/gateway/releases/download/v1.8.2/envoy-gateway-crds.yaml -
The Envoy Gateway Helm chart itself, with its own bundled CRDs disabled (step 2 already installed the ones that matter) and its controller name set to the value this project’s DNS-mode reconciler watches for:
Terminal window helm upgrade --install eg oci://docker.io/envoyproxy/gateway-helm --version 1.8.2 \-n envoy-gateway-system --create-namespace \--set crds.enabled=false \--set config.envoyGateway.gateway.controllerName=cfgateway.dreamfuselabs.com/dns-controllerkubectl -n envoy-gateway-system rollout status deploy/envoy-gateway --timeout=180s
-
-
A working
LoadBalancerimplementation on your cluster (a cloud provider’s, or MetalLB — see the callout below for a local kind cluster). -
A Cloudflare account and a zone (domain) you control.
-
Two Cloudflare API tokens — this project’s own controller and cert-manager’s DNS-01 solver never share one (see Credentials and Secrets for why):
- The controller’s own, scoped per Token Scopes’s DNS Mode table
(
Zone / DNS: Edit,Zone / Zone: Read, scoped to your account and zone). - A second, separate one for cert-manager’s own
ClusterIssuer— see cert-manager’s own token for the exact permission set (the same scope as the controller’s own, in DNS Mode).
- The controller’s own, scoped per Token Scopes’s DNS Mode table
(
Then install the chart itself:
-
Create the namespace:
Terminal window kubectl create namespace cloudflare-gateway-controller-system -
Create the pull Secret in it (the image and chart are private artifacts; there’s no anonymous install path):
Terminal window kubectl create secret docker-registry ghcr-pull \--docker-server=ghcr.io \--docker-username=<your-github-username> \--docker-password=<a token with read:packages scope> \--namespace cloudflare-gateway-controller-system -
Install the chart from GHCR:
Terminal window helm install cloudflare-gateway-controller oci://ghcr.io/dreamfuse-labs/charts/cloudflare-gateway-controller --version 0.4.0 --namespace cloudflare-gateway-controller-system --set 'imagePullSecrets[0].name=ghcr-pull'kubectl rollout status deployment/cloudflare-gateway-controller -n cloudflare-gateway-controller-system
Set ZONE=yourdomain.com, ACCOUNT_ID=<your Cloudflare account ID>,
CF_API_TOKEN=<the controller's token above>, and
CERT_MANAGER_API_TOKEN=<cert-manager's token above> in your shell for the steps below.
-
Store the credential (twice)
Section titled “Store the credential (twice)”Once for this project’s own controller, once for cert-manager’s DNS-01 solver, each from its own token — see Credentials and Secrets for why cert-manager needs its own copy, in its own namespace, as a separate token from the controller’s own (see cert-manager’s own token for the exact permission set) — never a copy of the controller’s own token, even though they happen to need the same scope here.
Terminal window kubectl create secret generic cloudflare-api-token \--namespace cloudflare-gateway-controller-system \--from-literal=api-token="$CF_API_TOKEN"kubectl create secret generic cloudflare-api-token \--namespace cert-manager \--from-literal=api-token="$CERT_MANAGER_API_TOKEN" -
Create a ClusterIssuer for Let’s Encrypt via Cloudflare DNS-01
Section titled “Create a ClusterIssuer for Let’s Encrypt via Cloudflare DNS-01”Use a real, non-blocklisted contact domain — Let’s Encrypt rejects registration for
example.com/.org/.net.$ZONE(a domain you actually control) works.Terminal window cat <<EOF | kubectl apply -f -apiVersion: cert-manager.io/v1kind: ClusterIssuermetadata:name: letsencryptspec:acme:server: https://acme-v02.api.letsencrypt.org/directoryemail: admin@$ZONEprivateKeySecretRef:name: letsencrypt-keysolvers:- dns01:cloudflare:apiTokenSecretRef:name: cloudflare-api-tokenkey: api-tokenselector:dnsZones: ["$ZONE"]EOFSwap in
https://acme-staging-v02.api.letsencrypt.org/directorywhile testing, to avoid Let’s Encrypt’s production rate limits — the staging server issues certificates no browser trusts, but it’s the right choice for working through this quickstart itself. If you do, add-kto the plaincurlin the Verify step below too — without it,curlrejects the staging certificate’s unknown issuer and exits60, even though everything else worked. -
Create a CloudflareGatewayConfiguration
Section titled “Create a CloudflareGatewayConfiguration”Unlike Tunnel Mode, DNS Mode’s
GatewayClass.parametersRefbelongs entirely to Envoy Gateway, so this configuration attaches to aGatewayviatargetRefsinstead:Terminal window cat <<EOF | kubectl apply -f -apiVersion: cfgateway.dreamfuselabs.com/v1alpha1kind: CloudflareGatewayConfigurationmetadata:name: dns-configspec:mode: dnsaccountID: "$ACCOUNT_ID"zoneAllowlist: ["$ZONE"]credentialSecretRef:namespace: cloudflare-gateway-controller-systemname: cloudflare-api-tokenkey: api-tokendnsDefaults:proxied: falseissuerRef:name: letsencryptkind: ClusterIssuertargetRefs:- group: gateway.networking.k8s.iokind: Gatewayname: my-gatewaynamespace: defaultEOFkubectl wait cloudflaregatewayconfiguration/dns-config \--for=condition=Accepted --timeout=30s -
Create the GatewayClass
Section titled “Create the GatewayClass”Envoy Gateway itself claims this class — this project’s own reconciler only manages the Cloudflare side (DNS records and certificates) for
Gateways that use it.Terminal window cat <<EOF | kubectl apply -f -apiVersion: gateway.networking.k8s.io/v1kind: GatewayClassmetadata:name: cloudflare-dnsspec:controllerName: cfgateway.dreamfuselabs.com/dns-controllerEOFkubectl wait gatewayclass/cloudflare-dns --for=condition=Accepted --timeout=60s -
Deploy a backend, Gateway, and HTTPRoute
Section titled “Deploy a backend, Gateway, and HTTPRoute”Terminal window cat <<EOF | kubectl apply -f -apiVersion: apps/v1kind: Deploymentmetadata:name: echospec:replicas: 1selector:matchLabels: {app: echo}template:metadata:labels: {app: echo}spec:containers:- name: echoimage: hashicorp/http-echo:1.0.0args: ["-listen=:8080", "-text=hello from dns mode"]ports: [{containerPort: 8080}]---apiVersion: v1kind: Servicemetadata:name: echospec:selector: {app: echo}ports: [{port: 80, targetPort: 8080}]EOFkubectl rollout status deployment/echo --timeout=60scat <<EOF | kubectl apply -f -apiVersion: gateway.networking.k8s.io/v1kind: Gatewaymetadata:name: my-gatewayspec:gatewayClassName: cloudflare-dnslisteners:- name: httpprotocol: HTTPport: 80hostname: "app.$ZONE"- name: httpsprotocol: HTTPSport: 443hostname: "app.$ZONE"tls:certificateRefs:- name: app-tls---apiVersion: gateway.networking.k8s.io/v1kind: HTTPRoutemetadata:name: echo-routespec:parentRefs:- name: my-gatewayrules:- backendRefs:- name: echoport: 80EOF(Note:
kubectl create deployment ... -- <args>sets the container’scommand, overridinghashicorp/http-echo’s own entrypoint entirely rather than appending flags to it — this is why the example above uses a plain YAMLDeploymentwithargs:instead, which appends to the entrypoint the wayhttp-echoexpects its flags.)Envoy Gateway owns
Gateway.statusentirely in this mode — wait for it directly:Terminal window kubectl wait gateway/my-gateway --for=condition=Accepted --timeout=60skubectl wait gateway/my-gateway --for=condition=Programmed --timeout=120sThen wait for the address it assigns (a real cloud LB, or a MetalLB-assigned address) to propagate through this project’s own auto-created
CloudflareDNSRecord, and for the auto-createdCertificateto issue (both are named deterministically from theGatewayname and listener hostname):Terminal window kubectl wait "$(kubectl get cloudflarednsrecord -o name)" --for=condition=Synced --timeout=60skubectl wait "$(kubectl get certificate -o name)" --for=condition=Ready --timeout=180s -
Verify
Section titled “Verify”Terminal window curl -sf "https://app.$ZONE"Should print
hello from dns mode. Checkkubectl get cloudflaregatewaystatusfor this project’s own Cloudflare-side readiness signal — distinct fromGateway.status, which stays entirely Envoy Gateway’s.
Cleanup
Section titled “Cleanup”kubectl delete httproute echo-routekubectl delete gateway my-gatewaykubectl delete deployment,service echokubectl delete gatewayclass cloudflare-dns
# Wait for the owned CloudflareDNSRecord's Kubernetes garbage collection to actually finish# (it has its own finalizer that deletes the real Cloudflare-side record first) before deleting# the configuration it authenticates through.for i in $(seq 1 30); do [ -z "$(kubectl get cloudflarednsrecord -o name 2>/dev/null)" ] && break; sleep 2; done
kubectl delete cloudflaregatewayconfiguration dns-configkubectl delete clusterissuer letsencryptkubectl delete secret cloudflare-api-token -n cloudflare-gateway-controller-systemkubectl delete secret cloudflare-api-token -n cert-managerThat wait matters: deleting the Gateway deletes the HTTPRoute’s target and the auto-created
CloudflareDNSRecord starts an asynchronous delete of its own — Kubernetes garbage-collects an
owned object only after its owner is gone, and the object’s own finalizer then calls the real
Cloudflare delete API. Deleting dns-config before that finishes hits a deliberate tradeoff: if
the CloudflareDNSRecord can no longer resolve its configuration by the time its own deletion
runs, there’s no credential left to authenticate a delete call, so its finalizer is removed
anyway rather than leaving the object stuck forever — and the real Cloudflare-side record is
orphaned, needing manual cleanup. The for loop above closes that race.
proxied vs DNS-only
Section titled “proxied vs DNS-only”This quickstart uses dnsDefaults.proxied: false — a DNS-only record pointing straight at your
LoadBalancer’s address — deliberately, so it works end-to-end regardless of whether you’re
running on a local kind cluster or a real cloud one. Set it true instead to route traffic
through Cloudflare’s edge (orange-cloud), but only on a cluster with a genuinely public
LoadBalancer address: Cloudflare’s API refuses to create a proxied record targeting a
private IP (error 9003), and a local kind+MetalLB cluster’s LoadBalancer address is always
private (Docker’s own VM-based networking model, not a kind-specific limitation) — there,
proxied: true reaches Accepted=True but never Synced=True, no matter how long you wait.
Next steps
Section titled “Next steps”- Routing — configure routes with
HTTPRouteandGRPCRoute. - Credentials and Secrets — rotate tokens, use GitOps, and
scope who can manage a
CloudflareGatewayConfiguration. - Access — protect a hostname with Cloudflare Access, identity providers, and service tokens.