Cloudflare Tunnel & Access Setup
This guide details how to configure Cloudflare Tunnel (cloudflared) and Cloudflare Zero Trust Access to expose local and remote Kubernetes development environments securely over browser-trusted HTTPS without modifying /etc/hosts or opening incoming router ports.
Architecture Overview
Public ingress traffic is routed through Cloudflare's global edge network directly into the cluster via an encrypted QUIC tunnel.
For complete technical specifications on edge TLS termination, single-level wildcard domain schemes (*-dev.tupynambalucas.dev), and reverse proxy topologies, refer to the Infrastructure Reference.
1. Creating the Cloudflare Tunnel
- Log in to the Cloudflare Zero Trust Dashboard.
- Navigate to Networks -> Tunnels and click Add a Tunnel.
- Select Cloudflared as the connector type and name the tunnel
workspace-minikube. - Select Docker as the environment type and copy the generated
TUNNEL_TOKEN(a base64-encoded string).
2. Public Hostname Routes
In the Public Hostnames tab of your tunnel configuration, register the following routes pointing to the internal Traefik Ingress Controller Service (http://traefik.platform.svc.cluster.local:80):
| Subdomain | Domain | Service Type | Service URL | Path |
|---|---|---|---|---|
agentgateway-dev | tupynambalucas.dev | HTTP | traefik.platform.svc.cluster.local:80 | / |
agentgateway-mcp-dev | tupynambalucas.dev | HTTP | traefik.platform.svc.cluster.local:80 | /mcp |
grafana-dev | tupynambalucas.dev | HTTP | traefik.platform.svc.cluster.local:80 | / |
headlamp-dev | tupynambalucas.dev | HTTP | traefik.platform.svc.cluster.local:80 | / |
memory-dev | tupynambalucas.dev | HTTP | traefik.platform.svc.cluster.local:80 | / |
memory-api-dev | tupynambalucas.dev | HTTP | traefik.platform.svc.cluster.local:80 | / |
traefik-dev | tupynambalucas.dev | HTTP | traefik.platform.svc.cluster.local:80 | / |
turbocache-dev | tupynambalucas.dev | HTTP | traefik.platform.svc.cluster.local:80 | / |
Instead of creating individual public hostnames, you can register a single wildcard public hostname *.development pointing to http://traefik.platform.svc.cluster.local:80.
3. Configuring Cluster Secrets & Deployment
- Add the tunnel token to your platform environment file (
platform/infrastructure/.env):CLOUDFLARE_TUNNEL_TOKEN_HUB=eyJ2Ijoi... - The
cloudflareddeployment inplatform/infrastructure/kubernetes/cloudflared.yamlreads this secret and connects automatically:pnpm k8s:up - Verify that the tunnel pod is connected:
kubectl get pods -n platform -l app=cloudflaredkubectl logs -n platform -l app=cloudflared --tail=20
4. Cloudflare Zero Trust Access Policies
To protect development endpoints from unauthorized public access:
Web User Interfaces (Grafana, Headlamp, Traefik, AgentGateway Admin)
- In Cloudflare Zero Trust, navigate to Access -> Applications -> Add an Application -> Self-hosted.
- Assign the public domain (e.g.,
grafana.development.tupynambalucas.dev). - Add an Allow policy restricting access to authorized developer email addresses via One-Time PIN (OTP).
AI Agent & MCP Ingress (agentgateway-mcp-dev.tupynambalucas.dev)
AI agents (such as Antigravity, Cursor, and CLI tools) communicate via JSON-RPC / SSE streams and cannot process interactive web browser login redirects.
- For
agentgateway-mcp-dev.tupynambalucas.dev, configure an Access Policy with Action: Bypass or assign a Service Token and set the tunnel path to/mcp. - This ensures non-browser clients can exchange payloads directly while internal security is enforced via AgentGateway CEL guardrails and API tokens.