Research: agentgateway as edge ingress replacing haproxy — cross-cluster routing via Cilium ClusterMesh #1527

Closed
opened 2026-08-13 19:21:42 +00:00 by ginjiruu · 3 comments
Owner

Research: can agentgateway replace haproxy as the edge ingress? Cross-cluster routing with Cilium ClusterMesh

Tracking the question "all in on agentgateway": collapse the per-cluster gateway/ingress stacks and the central haproxy fan-out into agentgateway as the single edge, once upstream OIDC web login lands (https://github.com/agentgateway/agentgateway/pull/1450).

Current state

clusters/portable/haproxy/ is the edge. A DaemonSet bound to the portable VIP receives all traffic on 80/443 and fans out:

  • 443 (L4, SNI inspection) → per-hostname to portable_kgateway_tcp (10.10.5.17:443), mini_kgateway_tcp (10.10.6.9:443), mini_tcp (10.10.6.0:443), cilium-ingress svc, plus non-k8s targets: azuracast VM (10.15.1.148:443) and kanidm ldaps (svc:3636). Everything uses send-proxy-v2.
  • 80 (L7, host map) → mini_http / portable_http / per-backend via mini.map / portable.map; ACME .well-known routed to the owning cluster's http backend.
  • 8443 → TLS-terminating HTTPS frontend (accept-proxy, wildcard cert) → portable_https.

Portable is internet-facing; mini is not directly reachable. Single-pod apps on mini (or any cluster that can't hold a public VIP) are reached via the haproxy SNI fan-out to that cluster's gateway/ingress node IP.

Findings (agentgateway capabilities, verified against 1.4.x docs + API ref)

  • Gateway API v1.6, ListenerSets (GEP-1713) ✅, HTTPRoute/GRPCRoute, TCPRoute (v1, experimental), TLSRoute/TLS passthrough (GEP-2643) ✅.
  • Static backends: AgentgatewayBackend.spec.static.{host,port} reaches arbitrary TCP/IP destinations — a non-k8s VM (the azuracast case) or a remote cluster's gateway IP is representable as a normal backend.
  • Dynamic Forward Proxy (AgentgatewayBackend.dynamicForwardProxy): routes by incoming HTTP host header or TLS SNI to the resolved destination. This is literally haproxy's model — one backend that dispatches on SNI/host, no per-hostname backend entries needed.
  • PROXY protocol: AgentgatewayPolicy.frontend.proxyProtocol exists (mode/version) — preserves client IP at the edge like send-proxy-v2 today.
  • DaemonSet edge: AgentgatewayParameters.workload.kind: DaemonSet is supported (haproxy is currently a DaemonSet; an edge agentgateway can be too).
  • Replicas/overlays: AgentgatewayParameters.deployment.spec.replicas / overlays map 1:1 to today's GatewayParameters.

The open problem: cross-cluster routing

GEP-1748 (Gateway API-native Multi-Cluster Services) is ❌ unsupported by agentgateway. Three ways to route a single-pod app on a non-internet-connected cluster:

  1. Cilium ClusterMesh (all clusters run Cilium) — Global Services surface remote-cluster Services as local ClusterIPs; agentgateway routes to them as ordinary Service backends. Removes the per-hostname haproxy backend entries entirely; mini and portable services become one namespace of local-looking services. This is the "native" answer and the direction to validate.
  2. Static AgentgatewayBackend pointing at the remote cluster's gateway/ingress node IP (mirrors today's mini_kgateway_tcp → 10.10.6.9) — works today, keeps the manual fan-out table.
  3. DFP backend dispatching on SNI to remote hosts — most haproxy-like, but DFP is a "route to arbitrary destinations" footgun; access controls needed.

Also relevant: BackendTunnel (HTTPS_PROXY-style egress) exists for firewalled/reverse-tunnel clusters — the same primitive lab/iac#28 relies on for apiserver access.

Integration with existing work

  • lab/iac#28 (kubeconfig distribution & connectivity) already picks agentgateway as a TLS-terminating proxy in front of each apiserver, doing RFC 8693 token exchange per request (Golden Path, lab/iac#38; blocker lab/iac#39 closed). If agentgateway is also the edge ingress, the apiserver routes and the app-ingress routes share one data plane + one policy model. Placement/cert decisions in #28 interact with where the edge agentgateway lives.
  • #1522 (k8s-apiserver OIDC flags) makes the apiserver itself accept Kanidm OIDC identity; combined with agentgateway's per-request token exchange (lab/iac#38) and — once merged — the browser OIDC login flow (agentgateway/agentgateway#1450), humans, machines, and app users all authenticate through the same agentgateway→Kanidm path.

Blocked by

  • Upstream OIDC web login in AgentgatewayPolicy — agentgateway/agentgateway#1450 (PR open; #2047 feature issue closed, superseded by the PR).

Questions to answer

  • Does the edge agentgateway live in portable (like haproxy) and route cross-cluster via ClusterMesh global services, or does each cluster run its own agentgateway with portable doing L4 SNI fan-out via DFP?
  • Does frontend.proxyProtocol accept PROXY v2 from the VIP as well as emit it (today haproxy does both accept and send)?
  • TCPRoute experimental status vs TLSRoute passthrough for the L4 (636 ldaps, non-http) workloads.
  • DFP access control story if used for arbitrary-SNI dispatch.
## Research: can agentgateway replace haproxy as the edge ingress? Cross-cluster routing with Cilium ClusterMesh Tracking the question "all in on agentgateway": collapse the per-cluster gateway/ingress stacks and the central haproxy fan-out into agentgateway as the single edge, once upstream OIDC web login lands (https://github.com/agentgateway/agentgateway/pull/1450). ## Current state `clusters/portable/haproxy/` is the edge. A DaemonSet bound to the portable VIP receives **all** traffic on 80/443 and fans out: - **443 (L4, SNI inspection)** → per-hostname to `portable_kgateway_tcp` (10.10.5.17:443), `mini_kgateway_tcp` (10.10.6.9:443), `mini_tcp` (10.10.6.0:443), `cilium-ingress` svc, plus non-k8s targets: azuracast VM (10.15.1.148:443) and `kanidm` ldaps (svc:3636). Everything uses `send-proxy-v2`. - **80 (L7, host map)** → `mini_http` / `portable_http` / per-backend via `mini.map` / `portable.map`; ACME `.well-known` routed to the owning cluster's http backend. - **8443** → TLS-terminating HTTPS frontend (`accept-proxy`, wildcard cert) → `portable_https`. Portable is internet-facing; mini is not directly reachable. Single-pod apps on mini (or any cluster that can't hold a public VIP) are reached via the haproxy SNI fan-out to that cluster's gateway/ingress node IP. ## Findings (agentgateway capabilities, verified against 1.4.x docs + API ref) - **Gateway API v1.6**, ListenerSets (GEP-1713) ✅, HTTPRoute/GRPCRoute, TCPRoute (v1, experimental), TLSRoute/TLS passthrough (GEP-2643) ✅. - **Static backends**: `AgentgatewayBackend.spec.static.{host,port}` reaches arbitrary TCP/IP destinations — a non-k8s VM (the azuracast case) or a remote cluster's gateway IP is representable as a normal backend. - **Dynamic Forward Proxy** (`AgentgatewayBackend.dynamicForwardProxy`): routes by **incoming HTTP host header or TLS SNI** to the resolved destination. This is literally haproxy's model — one backend that dispatches on SNI/host, no per-hostname backend entries needed. - **PROXY protocol**: `AgentgatewayPolicy.frontend.proxyProtocol` exists (mode/version) — preserves client IP at the edge like `send-proxy-v2` today. - **DaemonSet edge**: `AgentgatewayParameters.workload.kind: DaemonSet` is supported (haproxy is currently a DaemonSet; an edge agentgateway can be too). - **Replicas/overlays**: `AgentgatewayParameters.deployment.spec.replicas` / overlays map 1:1 to today's `GatewayParameters`. ## The open problem: cross-cluster routing GEP-1748 (Gateway API-native Multi-Cluster Services) is **❌ unsupported** by agentgateway. Three ways to route a single-pod app on a non-internet-connected cluster: 1. **Cilium ClusterMesh (all clusters run Cilium)** — Global Services surface remote-cluster Services as local ClusterIPs; agentgateway routes to them as ordinary Service backends. Removes the per-hostname haproxy backend entries entirely; `mini` and `portable` services become one namespace of local-looking services. This is the "native" answer and the direction to validate. 2. **Static `AgentgatewayBackend`** pointing at the remote cluster's gateway/ingress node IP (mirrors today's `mini_kgateway_tcp` → 10.10.6.9) — works today, keeps the manual fan-out table. 3. **DFP backend** dispatching on SNI to remote hosts — most haproxy-like, but DFP is a "route to arbitrary destinations" footgun; access controls needed. Also relevant: `BackendTunnel` (HTTPS_PROXY-style egress) exists for firewalled/reverse-tunnel clusters — the same primitive lab/iac#28 relies on for apiserver access. ## Integration with existing work - **lab/iac#28** (kubeconfig distribution & connectivity) already picks agentgateway as a **TLS-terminating proxy in front of each apiserver**, doing RFC 8693 token exchange per request (Golden Path, lab/iac#38; blocker lab/iac#39 closed). If agentgateway is also the edge ingress, the apiserver routes and the app-ingress routes share one data plane + one policy model. Placement/cert decisions in #28 interact with where the edge agentgateway lives. - **#1522** (k8s-apiserver OIDC flags) makes the apiserver itself accept Kanidm OIDC identity; combined with agentgateway's per-request token exchange (lab/iac#38) and — once merged — the browser OIDC login flow (agentgateway/agentgateway#1450), humans, machines, and app users all authenticate through the same agentgateway→Kanidm path. ## Blocked by - Upstream OIDC web login in `AgentgatewayPolicy` — agentgateway/agentgateway#1450 (PR open; #2047 feature issue closed, superseded by the PR). ## Questions to answer - Does the edge agentgateway live in portable (like haproxy) and route cross-cluster via ClusterMesh global services, or does each cluster run its own agentgateway with portable doing L4 SNI fan-out via DFP? - Does `frontend.proxyProtocol` accept PROXY v2 from the VIP as well as emit it (today haproxy does both accept and send)? - TCPRoute experimental status vs TLSRoute passthrough for the L4 (636 ldaps, non-http) workloads. - DFP access control story if used for arbitrary-SNI dispatch.
Author
Owner

Updating with cross-links and the ClusterMesh findings from the deeper dive.

Blocked by

  • Upstream OIDC web login in AgentgatewayPolicy — agentgateway/agentgateway#1450 (PR open; feature request #2047 closed as superseded by it).
  • Cross-cluster routing design decided in #1528 (Cilium ClusterMesh implementation).

Cross-cluster routing: decision

Implemented as #1528 — Cilium ClusterMesh between portable and mini using Global Services (service.cilium.io/global: "true"), not MCS-API. Rationale: agentgateway does not support GEP-1748 (ServiceImport backendRef), but Global Services materialize a real Service in each cluster, so agentgateway routes to it as an ordinary Service backend with zero GEP-1748 support needed. Full cross-referenced state (deployed Cilium 1.19.6 config, datapath/encryption/CIDR/BGP prereqs) is in #1528.

Follow-up: Egress Gateway + ClusterMesh

Not combinable. The Cilium docs state egress gateway is incompatible with Cluster Mesh — the gateway node selected by a CiliumEgressGatewayPolicy must be in the same cluster as the selected pods, and the two features cannot be combined. For pods in a meshed cluster that must reach cluster-external destinations with a fixed SNAT IP, keep egress policies per-cluster or route that traffic through a central gateway outside the fabric. Egress gateway also requires identityAllocationMode: crd, BPF masquerade, and kube-proxy replacement — portable already has kube-proxy replacement on; BPF masquerade (bpf.masquerade) is not explicitly set today.

Updating with cross-links and the ClusterMesh findings from the deeper dive. ## Blocked by - Upstream OIDC web login in `AgentgatewayPolicy` — [agentgateway/agentgateway#1450](https://github.com/agentgateway/agentgateway/pull/1450) (PR open; feature request #2047 closed as superseded by it). - Cross-cluster routing design decided in **#1528** (Cilium ClusterMesh implementation). ## Cross-cluster routing: decision Implemented as **#1528** — Cilium ClusterMesh between portable and mini using **Global Services** (`service.cilium.io/global: "true"`), not MCS-API. Rationale: agentgateway does not support GEP-1748 (ServiceImport backendRef), but Global Services materialize a real Service in each cluster, so agentgateway routes to it as an ordinary Service backend with zero GEP-1748 support needed. Full cross-referenced state (deployed Cilium 1.19.6 config, datapath/encryption/CIDR/BGP prereqs) is in #1528. ## Follow-up: Egress Gateway + ClusterMesh **Not combinable.** The Cilium docs state egress gateway is incompatible with Cluster Mesh — the gateway node selected by a `CiliumEgressGatewayPolicy` must be in the same cluster as the selected pods, and the two features cannot be combined. For pods in a meshed cluster that must reach cluster-external destinations with a fixed SNAT IP, keep egress policies per-cluster or route that traffic through a central gateway outside the fabric. Egress gateway also requires `identityAllocationMode: crd`, BPF masquerade, and kube-proxy replacement — portable already has kube-proxy replacement on; BPF masquerade (`bpf.masquerade`) is not explicitly set today. ## Related tickets updated - **#1528** — new implementation ticket (ClusterMesh + Global Services), cross-links #1527, lab/iac#28, #1522.
Author
Owner

Closing as superseded — the research question ("can agentgateway replace haproxy as the single edge?") was answered, but the fleet went a different direction than this issue proposed. Body left unchanged; this comment records the outcome.

What actually shipped (commits since this issue):

  • haproxy is removed (1ea00e60, moved to standby/). The edge is no longer haproxy.
  • The edge is now Cilium Gateway API (gateway/cilium-default, gatewayClassName: cilium) — not agentgateway.
  • Cross-cluster routing (mini apps) = per-hostname TLS passthrough (mini-passthrough ListenerSet + mini-* TLSRoutes) → a selectorless mini-cilium Service/EndpointSlice at the remote gateway node IP (10.10.6.14). This is the issue's option #2 (static backend to the remote gateway IP, "keeps the manual fan-out table"), rebuilt in Gateway API.
  • The issue's preferred option #1 (Cilium ClusterMesh / Global Services) was not pursued — no ClusterMesh/GlobalService manifests exist in the repo.

agentgateway's actual role now (not the edge):

  • AI gateway — clusters/portable/ai/.
  • apiserver authz-bridge — generic-templates/k8s-hub/; the mini + portable overlays wire the OIDC/token-exchange flow (custom oauth.animeteamspeak.moe / providers.animeteamspeak.moe CRDs + ExternalAuth filters), while mail stays pure passthrough.

The "Blocked by" no longer gates anything here: the edge is pure TLS passthrough and does no OIDC web login, so agentgateway/agentgateway#1450 (OIDC web login) is no longer the blocking item for the edge.

The one research finding that held up: the decision to standardize on generic Gateway API (ListenerSets, TLSRoute passthrough, selectorless Service + EndpointSlice for static backends) — implemented in Cilium rather than agentgateway.

Related live thread for the apiserver-access half: #1590 (k8s-hub: evaluate H2 Extended CONNECT for exec).

Closing as **superseded** — the research question ("can agentgateway replace haproxy as the single edge?") was answered, but the fleet went a different direction than this issue proposed. Body left unchanged; this comment records the outcome. **What actually shipped (commits since this issue):** - haproxy is **removed** (`1ea00e60`, moved to `standby/`). The edge is no longer haproxy. - The edge is now **Cilium Gateway API** (`gateway/cilium-default`, `gatewayClassName: cilium`) — *not* agentgateway. - Cross-cluster routing (mini apps) = **per-hostname TLS passthrough** (`mini-passthrough` ListenerSet + `mini-*` TLSRoutes) → a selectorless `mini-cilium` Service/EndpointSlice at the remote gateway node IP (10.10.6.14). This is the issue's **option #2** (static backend to the remote gateway IP, "keeps the manual fan-out table"), rebuilt in Gateway API. - The issue's preferred **option #1 (Cilium ClusterMesh / Global Services)** was **not** pursued — no ClusterMesh/GlobalService manifests exist in the repo. **agentgateway's actual role now (not the edge):** - **AI gateway** — `clusters/portable/ai/`. - **apiserver authz-bridge** — `generic-templates/k8s-hub/`; the mini + portable overlays wire the OIDC/token-exchange flow (custom `oauth.animeteamspeak.moe` / `providers.animeteamspeak.moe` CRDs + `ExternalAuth` filters), while mail stays pure passthrough. **The "Blocked by" no longer gates anything here:** the edge is pure TLS passthrough and does no OIDC web login, so agentgateway/agentgateway#1450 (OIDC web login) is no longer the blocking item for the edge. The one research finding that held up: the decision to standardize on **generic Gateway API** (ListenerSets, TLSRoute passthrough, selectorless Service + EndpointSlice for static backends) — implemented in Cilium rather than agentgateway. Related live thread for the apiserver-access half: **#1590** (k8s-hub: evaluate H2 Extended CONNECT for exec).
Author
Owner

Superseded — the edge is now Cilium Gateway API (haproxy removed), not agentgateway. Cross-cluster is per-hostname TLS passthrough, not ClusterMesh. See the closing comment for the full breakdown.

Superseded — the edge is now Cilium Gateway API (haproxy removed), not agentgateway. Cross-cluster is per-hostname TLS passthrough, not ClusterMesh. See the closing comment for the full breakdown.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lab/clusters#1527
No description provided.