Expose a Service through Cloudflare Tunnel
Publish a Service on a public hostname with a CloudflareTunnel, Gateway, and HTTPRoute. Flareway creates the tunnel, DNS record, and Envoy routes.
Before you start
Section titled “Before you start”This guide changes a real Cloudflare account. You need:
- Flareway installed as in Install.
- The
CloudflareAccountandGatewayClass/flarewayfrom Connect a Cloudflare account. The account showsAcceptedandCredentialsValidbothTrue, its token has the tunnel and DNS capabilities, and the class showsAccepted=True. - A namespace that matches the account’s grant. The examples use
default. - A hostname in a zone the grant allows. Because this route has no Access application, the hostname must also be listed in the grant’s
unprotectedHostnames. - A Service to publish in the same namespace. The examples send traffic to
example-serviceon port 8080.
The manifests below come from config/samples/. Replace example.com, example-account, and example-service with your own names.
Create the CloudflareTunnel
Section titled “Create the CloudflareTunnel”A CloudflareTunnel declares the remote tunnel, its DNS policy, and the listeners it serves. This is config/samples/flareway_v1alpha1_cloudflaretunnel.yaml:
apiVersion: flareway.bhyoo.com/v1alpha1kind: CloudflareTunnelmetadata: name: public namespace: defaultspec: accountRef: name: example-account tunnel: name: flareway-example-public configuration: # Gateway mode is the sole writer of ingress assembled from Gateway API resources. mode: Gateway managementPolicy: Managed adoption: mode: None deletionPolicy: Delete dns: mode: Managed recordComment: example public tunnel proxied: true ttl: 1 listeners: - name: web exposure: PublicaccountRefnames the account whose grant must allow this namespace.tunnel.nameis the tunnel name in Cloudflare.configuration.mode: Gatewaymakes the Gateway the only writer of the tunnel’s ingress configuration.managementPolicy: Managedwithadoption.mode: Nonecreates a new tunnel instead of taking over an existing one.deletionPolicy: Deleteremoves the remote tunnel when you delete this object. Ownership and adoption covers the other policies.dns.mode: Managedlets Flareway write the DNS record.proxied: truerequiresttl: 1, which means automatic.listenersmarks the Gateway listenerwebas public.
Create the Gateway
Section titled “Create the Gateway”This is config/samples/gateway_v1_gateway.yaml, unchanged:
apiVersion: gateway.networking.k8s.io/v1kind: Gatewaymetadata: name: public namespace: defaultspec: gatewayClassName: flareway infrastructure: parametersRef: group: flareway.bhyoo.com kind: CloudflareTunnel name: public listeners: - name: web hostname: app.example.com port: 80 protocol: HTTP allowedRoutes: namespaces: from: Sameinfrastructure.parametersRef binds the Gateway to the CloudflareTunnel named public in the same namespace. That reference is the whole link; the Gateway carries no Flareway annotations. Cloudflare owns edge TLS for public listeners, so the listener has no certificateRefs.
Create the HTTPRoute
Section titled “Create the HTTPRoute”This is config/samples/gateway_v1_httproute.yaml, unchanged:
apiVersion: gateway.networking.k8s.io/v1kind: HTTPRoutemetadata: name: public namespace: defaultspec: parentRefs: - name: public sectionName: web hostnames: - app.example.com rules: - matches: - path: type: PathPrefix value: / backendRefs: - name: example-service port: 8080The route attaches to the web listener and sends every path on app.example.com to example-service. Apply the three manifests with kubectl apply -f.
What Flareway creates
Section titled “What Flareway creates”- The Cloudflare Tunnel
flareway-example-public. - A data-plane Deployment,
flareway-gw-publicindefault, whose pod runscloudflaredand Envoy.cloudflaredopens outbound connections to Cloudflare’s edge, so the cluster needs no inbound ports or public IPs. - A proxied CNAME record for
app.example.comthat points to the tunnel, with Flareway’s ownership marked in the record comment. - Envoy routes for the
HTTPRoute, streamed from the controller over xDS.cloudflaredforwards requests to Envoy over loopback, and Envoy applies the route rules.
Verify
Section titled “Verify”kubectl get gateway -n default publickubectl get cloudflaretunnel -n default publicWait for the Gateway’s PROGRAMMED column to show True. Flareway reports Programmed=True only after edge DNS, tunnel sessions, the xDS configuration, and the Envoy data plane have all converged. The CloudflareTunnel shows the remote tunnel ID and READY as True.
If Programmed stays False, run kubectl describe gateway -n default public and read the condition’s reason and message. Reason Pending names the gate that has not converged yet. DNSReady=False on the tunnel means the zone is not granted or discovered, or an existing record carries a foreign ownership comment. Troubleshooting lists every condition.
Once the Gateway is programmed, request the hostname:
curl https://app.example.com/The response comes from example-service.
Go further
Section titled “Go further”Header, method, and query matches, rewrites, mirrors, and weighted backends are standard HTTPRoute fields. HTTP routing lists what Flareway supports.