ADR-0005: Gateway API with Envoy Gateway instead of ingress-nginx
- Status: Accepted
- Date: 2026-11-10
- Decision owners: Homelab maintainers
- Plan and execution record: ingress-nginx to Envoy Gateway migration
- Operating docs: Ingress, Exposing an app with Gateway API
Context
Two ingress-nginx controllers (nginx-internal on 192.168.193.1, nginx-external on
192.168.193.4) served every app. Three things pinned the cluster to them:
- nginx-only behaviour. Apps relied on
configuration-snippet/server-snippetrewrites, redirects, per-app timeout annotations andauth-snippetskip paths. These live in annotations that only ingress-nginx understands. - Authentication through a shared oauth2-proxy. One oauth2-proxy (
auth.grigri.cloud) with one Kanidm client and a shared cookie on.grigri.cloudfronted every protected Ingress throughauth-url/auth-signin. - The tenant platform. The hosted tenant (Forkline Remote) needs Gateway API: experimental
channel CRDs, a shared external Gateway with HTTPS listeners plus a TLS passthrough listener, and
routes (
HTTPRoute,TLSRoute) in its own namespaces.
Forgejo SSH (29518) and the public ports 80 and 443 reached the cluster through one pfSense alias
pointing at the nginx VIP.
Decision
Replace both controllers and the shared oauth2-proxy with Envoy Gateway (Gateway API plus Envoy Gateway policies). The plan records the decisions D1 to D9; in short:
- Side by side, two switches (D1). Envoy Gateway ran next to nginx on new VIPs. Each app got its routes and was verified against the new VIPs while nginx served real traffic; then one internal switch (DNS) and one external switch (the pfSense alias plus three DNS Resolver host overrides). nginx stayed idle as the rollback path until both switches had soaked, then both controllers were removed together (D8).
- Two Gateways, two VIPs (D2).
internalon192.168.193.13(LAN) andexternalon192.168.193.14(public, behind the same pfSense alias). Forgejo SSH is aTCPRouteon the external Gateway and moves with the same alias. Each Gateway has its ownEnvoyProxy, Deployment and Service. - Native OIDC against Kanidm (D3). Per protected route an Envoy Gateway
SecurityPolicydoes OIDC and a JWT check; oauth2-proxy is removed. Each app has its own Kanidm OAuth2 client, its own<app>-usersgroup and its own claim (access=[<app>]); there is no shared client and no global group. Recipe: Authentication. - Port everything (D5). Every nginx-only behaviour was ported and verified (rewrites,
redirects, Lua
EnvoyExtensionPolicy, backend TLS, skip paths); none was dropped. Snippets are translated by behaviour, never by tool. - Same DNS mechanism (D6, D7). external-dns publishes names to Cloudflare from annotated
routes; the internal records point at
.13. - Cilium BGP, no ECMP (D9). Both Services are
LoadBalancerwithloadBalancerClass: io.cilium/bgp-control-planeandexternalTrafficPolicy: Local. Proxies are placed onprusik, so each VIP keeps one path as before; ECMP is not used. - Tenant runners (D4). The tenant runner wildcard was bridged to nginx by a TLS passthrough
listener until the tenant emitted
HTTPRoutes; the bridge was then replaced by a terminating runner listener.
Consequences
Operating rules that follow from the choice (details in the linked docs):
- Listener drains. All HTTPS hosts of a Gateway share one Envoy listener. A new or removed
SecurityPolicyorEnvoyExtensionPolicy, or a certificate change, replaces a filter chain and closes connections still open after the 60 s drain.HTTPRoute-only changes drain nothing. Batch listener-affecting changes and avoid them during long transfers: listener drain. - Timeouts are idle, not total. nginx timeouts were idle timeouts; Envoy's route request timeout
is a total limit. Gateway defaults are
requestTimeout: 0sandstreamIdleTimeout: 60s; longer idle values go in a routeBackendTrafficPolicywithmergeType: StrategicMerge, never intimeouts.request. - Request bodies are streamed. Envoy does not buffer requests as nginx did, so a slow upload reaches the app as a slow upload. There is no body-size limit.
- Underscore headers are dropped. Request headers whose name contains an underscore do not reach the backend; an app that needs one has to rename it.
- Cookie size limit for OIDC. The Envoy OAuth2 session lives in cookies per host and browsers
drop cookies above 4096 B. The
groupsscope puts every group in the ID token and overflows the limit, so scopes areopenid profile emailand authorization uses the per-app claim: ID token cookie size. Moving from oauth2-proxy cost one extra login per app (new per-host cookies). Kanidm has no end-session endpoint, so logout clears only the Envoy cookies. - Gateway-wide settings must be explicit. ALPN
[h2, http/1.1]is pinned (hostname-scoped TLS listeners otherwise drop h2), HSTS is the only added header, route-level policies useStrategicMerge, and compression is per route and never on MinIO/S3 hosts (it breaks SigV4). - Certificates live on the Gateways (
envoy-gatewaynamespace, DNS-01). Routes carry nocert-manager.io/*annotation and apps create no TLS secrets. A route with an.internal.host must not reference the external Gateway. - CRDs. Gateway API experimental channel, synced server-side. Argo CD has no health check for
several of the kinds (
TCPRoute,ReferenceGrant,EnvoyProxy,HTTPRouteFilter): read their status by hand. - NetworkPolicies must admit the Envoy proxy pods, and egress toward them uses the container
ports
10443and10080, not443and80. - external-dns is upsert-only and opt-in (
external-dns.kubernetes.io/enabled); the external Gateway supplies the CNAME target. Changing a name's record type needs a manual Cloudflare edit. - No nginx rollback path. The side-by-side rollback (pfSense alias and overrides back to the nginx VIPs) ended with the removal; restoring nginx means reverting the removal commits in git.
Alternatives considered
- Big bang, Envoy takes
.1and.4. No per-app testing before real traffic, one switch for everything, and rollback means reverting git and waiting for Argo CD while Argo CD, Vault and the identity provider may be unreachable. Rejected for the side-by-side strategy. - Keep oauth2-proxy behind Envoy
extAuth(SecurityPolicy.extAuth.http). It works and the tenant's own web auth uses it with its own oauth2-proxy (auth-only mode, so the browser sees oauth2-proxy's sign-in redirect, as EnvoyextAuthhas noauth-signinequivalent). Not chosen for the homelab apps: native OIDC removes oauth2-proxy and its shared Kanidm client. - A global Kanidm group on top of the per-app groups (a
homelab-userstier required by every policy). Not taken: per-app groups only, so Kanidm decides who may log in to each app and Envoy re-checks the same group. - Converting Ingresses with a tool (
ingress2gatewayand similar). They silently drop auth and snippets; conversion is by behaviour, verified withcurl --resolveagainst the new VIP. - BGP ECMP across nodes. Not now (D9): placement keeps proxies on
prusik, one path per VIP. - Standard-channel Gateway API CRDs. Enough for
v1TCPRouteandTLSRoute, but the experimental channel keeps servingv1alpha2, which the tenant still uses.