Skip to content

Case Study: Zero-Trust Hybrid Ingress Engine & CGNAT Traversal

Engineering Dimension Production Specification
Architecture Pattern Zero Trust Network Access (ZTNA) & Edge Reverse Ingress
Core Technologies Cloudflare Zero Trust, cloudflared (QUIC/HTTP2), Traefik Ingress Controller
Primary Code Paths kubernetes/platform/cloudflared/, kubernetes/platform/traefik/
Relevant Decisions ADR-006, ADR-012
Operational Status Production Verified (Latency <15ms, Zero Open Ports, Edge WAF Active)

1. Executive Summary

Residential internet connections operate behind Carrier-Grade NAT (CGNAT), preventing inbound connections without opening firewall ports, exposing home IPs, or leasing expensive static IPv4 addresses.

This project engineered a production-grade, zero-trust public ingress architecture that safely terminates public web traffic, administrative portals, and external webhooks into a private on-premise Kubernetes cluster. By replacing an experimental cross-continental cloud relay with Cloudflare Zero Trust Anycast Tunnels (cloudflared), the solution slashed edge latency by ~97% (from ~500ms to <15ms), eliminated cloud egress and NAT surcharge costs, and completely eradicated the external network attack surface by maintaining zero open inbound firewall ports.


2. The Problem: The Ingress Trilemma

When exposing on-premise Kubernetes workloads to public users and automated webhooks, platform engineers face three conflicting requirements:

  1. Security & Attack Surface: Exposing home router ports (80/443) invites brute-force SSH attacks, automated port scans (e.g., Shodan, Censys), and volumetric DDoS assaults directly onto the residential network.
  2. CGNAT Connectivity Barriers: Residential ISPs assign non-routable private IPv4 addresses (100.64.0.0/10) to customer routers. Behind Carrier-Grade NAT, conventional port-forwarding and dynamic DNS (DDNS) rules are completely non-functional.
  3. Latency Physics & Cloud Egress: Earlier iterations routed traffic through a cloud VM in South Carolina (us-east1) running WireGuard. Traffic traversed two continents:

$$\text{Visitor (India)} \xrightarrow{220\text{ms}} \text{GCP us-east1 (USA)} \xrightarrow[\text{WireGuard}]{220\text{ms}} \text{Home Proxmox} \xrightarrow{220\text{ms}} \text{GCP} \xrightarrow{220\text{ms}} \text{Visitor}$$

This added a severe ~450ms–500ms latency penalty per request and generated recurring cloud bandwidth egress bills.


3. High-Level Architecture & Edge Ingress Flow

Traffic Flow Topology:
[ Public User / Recruiter / Webhook ]
              │ HTTPS (TLS 1.3 / Port 443)
              ▼
[ Cloudflare Anycast Edge Network (Mumbai / Delhi / Chennai) ]
              │ • Layer 7 WAF & DDoS Shield
              │ • Edge SSL Certificate Termination
              │ • Cloudflare Access SSO (Google OAuth 2.0 for Admin)
              │
              │ Encrypted Outbound QUIC Stream (Port 7844 / 443)
              ▼
[ cloudflared Connector Pod (k3s-prod: namespace platform) ]
              │ HTTP Cluster-Internal Routing
              ▼
[ Traefik Ingress Controller (kube-system: Port 80) ]
              │ Path & Host Header Matching
              ├── docs.vijaysingh.cloud  ──► Homelab Docs Portal
              ├── hooks.vijaysingh.cloud ──► n8n Automation Webhook
              └── dash.vijaysingh.cloud  ──► Homepage Dashboard (SSO Protected)

Global Multi-Cloud & Network Ingress Topology


4. Key Architectural Implementations

1. Outbound-Only QUIC/HTTPS Tunnels

The in-cluster cloudflared daemon establishes four persistent outbound UDP connections over port 7844 (with automatic fallback to TCP 443 HTTP/2) to Cloudflare's nearest Anycast data centers. Because connections originate from inside the cluster:

  • The residential router firewall blocks all inbound traffic.
  • No public IP address is associated with the home infrastructure.
  • Automated internet scanners perceive the residential IP as completely dark.
# In-Cluster Tunnel Connector (kubernetes/platform/cloudflared/cloudflared.yaml)
apiVersion: apps/v1
kind: Deployment
metadata:
  name: cloudflared
  namespace: platform
spec:
  replicas: 1
  template:
    spec:
      containers:
      - name: cloudflared
        image: cloudflare/cloudflared:latest
        args:
        - tunnel
        - --no-autoupdate
        - run
        - --token
        - $(TUNNEL_TOKEN)
        resources:
          limits:
            cpu: 300m
            memory: 128Mi
          requests:
            cpu: 50m
            memory: 64Mi

2. High-Availability Traefik Mapping

Rather than maintaining discrete ingress tunnel connectors for every service, cloudflared proxies all incoming hostnames to the cluster's internal Traefik Ingress Controller:

  • docs.vijaysingh.cloud $\to$ http://traefik.kube-system.svc.cluster.local:80
  • hooks.vijaysingh.cloud $\to$ http://traefik.kube-system.svc.cluster.local:80
  • dash.vijaysingh.cloud $\to$ http://traefik.kube-system.svc.cluster.local:80

Traefik evaluates native Kubernetes Ingress and IngressRoute resources, managing internal TLS headers, middleware, and request forwarding.

3. Edge Identity Protection with Cloudflare Access (SSO)

Administrative web portals (such as the Homepage dashboard at dash.vijaysingh.cloud) are protected at the Cloudflare edge using Cloudflare Access Zero Trust policies:

  • Unauthenticated requests are intercepted at the edge before packets reach the homelab.
  • Users authenticate via Google OAuth 2.0 with hardware security key (FIDO2/WebAuthn) support.
  • External webhook endpoints (e.g. hooks.vijaysingh.cloud for n8n) bypass SSO and are protected by HMAC SHA-256 webhook signatures.

5. Verification & Live Production Health

1. Edge Latency & TTFB Benchmarks

Benchmarked using curl against edge points-of-presence in India:

curl -w "DNS: %{time_namelookup}s | Connect: %{time_connect}s | TTFB: %{time_starttransfer}s | Total: %{time_total}s\n" \
  -o /dev/null -s https://docs.vijaysingh.cloud

Actual Result:

DNS: 0.005s | Connect: 0.012s | TTFB: 0.028s | Total: 0.034s
Sub-35ms total response time for fully rendered static documentation pages.

2. Port Stealth Verification

External Nmap scan targeting residential WAN IP:

nmap -Pn -p 80,443,51820 <RESIDENTIAL_IP>
Actual Result: All ports report filtered / stealthed. Zero responsive listening sockets.


6. Quantified Engineering Impact

Performance Dimension Legacy Cloud Relay (v2) Cloudflare Zero Trust (Current) Engineering Yield
Roundtrip Request Latency ~450ms – 550ms < 15ms ~97% Latency Reduction
Open Firewall Ports 1 (UDP 51820 on cloud VM) 0 (Zero open inbound ports) Attack Surface Completely Neutralized
Cloud Bandwidth Surcharge ~$10 – $15 / month Cost-Optimized (Zero Egress Costs) 100% Cloud Ingress Cost Elimination
Edge Redundancy Single compute VM in us-east1 Multi-PoP Anycast (Global Mesh) Enterprise High Availability Edge
DDoS & Layer 7 Defense Basic iptables rate-limiting Cloudflare Global Threat Intelligence Automated Volumetric Attack Absorption