envoy-guide
Module 7 · Going Deeper·18 min·advanced

Envoy Gateway and the Kubernetes Gateway API

Run Envoy as a K8s ingress / API gateway with declarative HTTPRoute / GRPCRoute / SecurityPolicy CRDs.

What Envoy Gateway is

Envoy Gateway is the upstream project that packages Envoy as a Kubernetes ingress / API gateway, configured via the Kubernetes Gateway API (gateway.networking.k8s.io). You install one controller; it watches Gateway API resources and programs Envoy via xDS.

Why it exists:

  • Ingress is too thin — no method matching, no header routing, no retries, no real TLS story.
  • Direct xDS is too low-level for ingress teams.
  • ingress-nginx is in maintenance mode and lacks gRPC, JWT, and rich retry support.

Gateway API is the K8s sig-network successor to Ingress, designed by Google, F5, Solo, and the Istio team to be vendor-neutral. Envoy Gateway is the reference implementation that runs vanilla upstream Envoy.

The four resources you'll touch

ResourceWhat it does
GatewayClassSelects which controller programs the gateway
GatewayDeclares listeners (port, protocol, TLS)
HTTPRoute / GRPCRouteMatch → backendRefs (with weights)
SecurityPolicy / BackendTrafficPolicyEnvoy-specific extensions (auth, rate-limit, timeouts, retries)

A complete minimal stack

YAML
# 1. GatewayClass — pick the controller
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata: { name: eg }
spec:
  controllerName: gateway.envoyproxy.io/gatewayclass-controller
---
# 2. Gateway — listener + TLS
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata: { name: edge, namespace: web }
spec:
  gatewayClassName: eg
  listeners:
  - name: https
    port: 443
    protocol: HTTPS
    tls:
      mode: Terminate
      certificateRefs:
      - { kind: Secret, name: edge-tls }
    allowedRoutes:
      namespaces: { from: All }            # see pitfall below
---
# 3. HTTPRoute — /api -> two backends, 90/10 canary
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata: { name: api, namespace: app }
spec:
  parentRefs:
  - { name: edge, namespace: web }
  hostnames: ["api.example.com"]
  rules:
  - matches:
    - path: { type: PathPrefix, value: /api }
    backendRefs:
    - { name: api-svc,    port: 8080, weight: 90 }
    - { name: api-canary, port: 8080, weight: 10 }
    timeouts: { request: 5s }
    retry:    { codes: [502, 503], attempts: 3, backoff: 100ms }

Install the controller:

Shell
helm install eg oci://docker.io/envoyproxy/gateway-helm \
  --version v1.2.0 \
  -n envoy-gateway-system --create-namespace

Three onboarding traps

allowedRoutes.namespaces is 'Same' by default

An HTTPRoute in namespace app referencing a Gateway in namespace web is silently ignored unless the Gateway opts in via from: All or a label selector. The route shows Accepted=False in its status — always kubectl describe httproute first.

TLS Secret must be in the Gateway's namespace

Cross-namespace secret refs require a ReferenceGrant. Cert-manager users hit this constantly: they put the Certificate in the cert-manager namespace and the Gateway in web, then wonder why the listener is Programmed=False.

No xDS-level features without policy CRs

Rate limit, JWT auth, WASM, and ext_proc are not part of Gateway API itself. Envoy Gateway adds them via SecurityPolicy, BackendTrafficPolicy, and EnvoyExtensionPolicy. Teams migrating from Istio expect annotations and find none — you write a policy CR that targets the route via targetRefs.

Adding JWT auth via SecurityPolicy

YAML
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: SecurityPolicy
metadata: { name: api-jwt, namespace: app }
spec:
  targetRefs:
  - { group: gateway.networking.k8s.io, kind: HTTPRoute, name: api }
  jwt:
    providers:
    - name: idp
      issuer: https://auth.example.com/
      audiences: ["api"]
      remoteJWKS: { uri: https://auth.example.com/.well-known/jwks.json }

That single CR generates the same jwt_authn filter you'd write by hand in Lesson 19 — but applied to the right HTTPRoute via targetRefs.

vs Istio Gateway

Istio Gateway is the older, mesh-coupled API (networking.istio.io/v1beta1). Powerful, but ties you to Istio's control plane and CRDs.

Envoy Gateway is mesh-agnostic, uses standard Gateway API resources that work the same on Kong, Cilium, Contour, and HAProxy controllers, and ships a stripped-down focused control plane.

For pure ingress (no mesh), Envoy Gateway is becoming the default — and it's why teams are migrating off ingress-nginx, which is in maintenance mode.

Hands-on: from zero to JWT-protected canary in one cluster

Hands-on · Install Envoy Gateway, ship a canary, add auth
  1. Spin up kind:
Shell
kind create cluster --name eg-demo
  1. Install Envoy Gateway with Helm (command above).

  2. Apply the three core manifests (GatewayClass + Gateway + HTTPRoute). Then:

Shell
kubectl get gateway,httproute -A

Confirm Programmed=True on the Gateway and Accepted=True on the route.

  1. Port-forward and test the canary:
Shell
kubectl -n envoy-gateway-system port-forward svc/envoy-web-edge 8443:443
curl -k --resolve api.example.com:8443:127.0.0.1 https://api.example.com:8443/api
  1. Add the SecurityPolicy from above. Without a token, you should now get 401:
Shell
curl -k -i --resolve api.example.com:8443:127.0.0.1 \
  https://api.example.com:8443/api
# expect: HTTP/2 401
  1. Tear down: kind delete cluster --name eg-demo.
Real-world example · Northwave Logistics (40 microservices on K8s)
Problem
They ran ingress-nginx for 40 microservices. Two CVEs in ingress-nginx and a hard requirement for gRPC-Web pushed them to evaluate alternatives. ingress-nginx is in maintenance mode; they needed JWT, retries, and gRPC routing in the gateway, not in app code.
Envoy solution
Installed Envoy Gateway. Converted Ingress to HTTPRoute (and GRPCRoute for the new gRPC services) with a small script. Added JWT via SecurityPolicy. Decommissioned nginx. Same Envoy data plane they already use for east-west service mesh — one set of logs, metrics, and operational knowledge across north-south + east-west.

You finished the deep dive

Module 7 in one breath:

  • WASM — custom filter logic, near-native, sandboxed.
  • Lua — quick scripts, no toolchain.
  • ext_proc — bidirectional body mutation via gRPC. AI/PII work goes here.
  • Dynamic forward proxy — egress to anywhere with one cluster.
  • SDS — TLS cert rotation without restarts.
  • Outlier detection — passive health checks that actually work, if you avoid the panic-threshold trap.
  • Envoy Gateway — Envoy as a Kubernetes ingress / API gateway, declarative.

Combined with Modules 1-6, you now have a deeper-than-the-official-docs understanding of Envoy. Go ship something.

Quick check

An HTTPRoute in namespace 'app' references a Gateway in namespace 'web' and shows Accepted=False. Most likely cause?

Practical task
Finish the quick check and tick off the task to unlock.
Quick checkTasks 0/4