Deploying Envoy Gateway on Kubernetes: Replacing Ingress with the Modern Gateway API

DevOps tutorial - IT technology blog
DevOps tutorial - IT technology blog

Quick Start: From Scratch to Your First HTTPRoute in 5 Minutes

Six months ago, our platform team finally pulled the plug on our brittle NGINX Ingress controller setup across three production clusters. We standardized on Envoy Gateway instead. If you want a working instance right now without wading through 30-page architecture specs, follow this fast track.

Step 1: Install Gateway API CRDs and the Envoy Gateway Controller

Start by installing the standard Kubernetes Gateway API Custom Resource Definitions (CRDs). Then pull down the official Envoy Gateway Helm chart:

# Install standard Gateway API CRDs (v1.1.0)
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.1.0/standard-install.yaml

# Install the Envoy Gateway Helm chart
helm install eg oci://docker.io/envoyproxy/gateway-helm \
  --version v1.1.0 \
  -n envoy-gateway-system \
  --create-namespace

# Wait for the controller deployment to be ready (usually takes under 30 seconds)
kubectl wait --timeout=2m -n envoy-gateway-system deployment/envoy-gateway --for=condition=Available

Step 2: Deploy the Gateway, Demo Backend, and HTTPRoute

The standard installation comes with an Envoy-managed GatewayClass named eg. Create a Gateway, run two replicas of a lightweight echo server, and bind an HTTPRoute to handle incoming traffic:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: prod-gateway
  namespace: default
spec:
  gatewayClassName: eg
  listeners:
    - name: http
      protocol: HTTP
      port: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: demo-app
  namespace: default
spec:
  replicas: 2
  selector:
    matchLabels:
      app: demo-app
  template:
    metadata:
      labels:
        app: demo-app
    spec:
      containers:
        - name: echo
          image: hashicorp/http-echo:0.2.3
          args: ["-text=Hello from Envoy Gateway!"]
          ports:
            - containerPort: 5678
---
apiVersion: v1
kind: Service
metadata:
  name: demo-service
  namespace: default
spec:
  ports:
    - port: 5678
      targetPort: 5678
  selector:
    app: demo-app
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: demo-route
  namespace: default
spec:
  parentRefs:
    - name: prod-gateway
  hostnames:
    - "api.example.local"
  rules:
    - matches:
      - path:
          type: PathPrefix
          value: /
      backendRefs:
        - name: demo-service
          port: 5678

Save this manifest as gateway-demo.yaml and apply it:

kubectl apply -f gateway-demo.yaml

Step 3: Test Routing

When you apply the Gateway resource, Envoy Gateway automatically provisions an underlying Envoy proxy deployment and a Kubernetes Service of type LoadBalancer. Grab that external address:

# For cloud environments (EKS, GKE, AKS)
GATEWAY_IP=$(kubectl get gateway prod-gateway -o jsonpath='{.status.addresses[0].value}')

# Test with your custom Host header
curl -H "Host: api.example.local" http://${GATEWAY_IP}/

The terminal will return Hello from Envoy Gateway!. That is all it takes to spin up a working baseline.

Deep Dive: Why Gateway API Beats Legacy Ingress

Kubernetes Ingress served us well for years as the default Layer-7 entry point. But as our microservices grew past 120 individual services, Ingress hit structural limits that forced us into brittle configuration hacks.

The Legacy Ingress Dilemma

The biggest flaw in the legacy Ingress spec is its single-object design:

  • Monolithic Ownership: Platform engineers managing public IPs and TLS certificates had to edit the exact same YAML manifests as developers who only wanted to route /orders to a new pod. One misconfigured path prefix could break an entire team’s release.
  • Annotation Sprawl: Basic operational necessities—URL rewrites, connection timeouts, rate limits, and canary weights—never existed in the core Ingress specification. Every controller vendor invented proprietary annotations like nginx.ingress.kubernetes.io/canary-weight. Migrating between Traefik, HAProxy, and NGINX meant rewriting hundreds of manifests from scratch.
  • Silent Validation Failures: A syntax error in an annotation rarely failed validation at apply time. Instead, the controller often crashed or quietly refused to reload route tables, taking down routes across unrelated workloads.

How Gateway API Decouples Roles

The Gateway API fixes these structural flaws by splitting traffic management across three distinct personas:

  1. GatewayClass (Infrastructure Provider): Managed by cloud administrators. It defines the controller implementation (such as Envoy Gateway) and cluster-wide parameters.
  2. Gateway (Platform / Cluster Operator): Managed by platform and SRE teams. It allocates public IPs, configures TLS termination, and binds listening ports (such as 443 and 80).
  3. HTTPRoute / GRPCRoute (Application Developer): Managed by feature teams. Developers attach routes to an existing Gateway using parentRefs. They configure path prefixes, header matching, and target backend services without touching cluster infrastructure.

Envoy Gateway pairs this clean separation of duties with Envoy’s battle-tested C++ data plane. Handcrafting Envoy configuration usually requires hundreds of lines of complex dynamic discovery service (xDS) boilerplate. Envoy Gateway acts as a compiler. It continuously watches declarative Gateway API resources and compiles them into verified, zero-downtime xDS updates automatically.

Advanced Production Routing: Canary Splitting, Rate Limiting & TLS

Basic routing is easy. Handling real production traffic requires granular traffic shifting, automated security policies, and robust TLS handshakes.

1. Header-Based Routing and Canary Traffic Splitting

Shifting production traffic between two releases previously required an external service mesh or custom Lua scripts. With HTTPRoute, you can route internal QA testers using custom headers while splitting general public traffic 90/10 across releases:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: payments-route
  namespace: default
spec:
  parentRefs:
    - name: prod-gateway
  hostnames:
    - "payments.example.com"
  rules:
    # Route internal testers running canary builds
    - matches:
        - headers:
            - type: Exact
              name: X-Release-Track
              value: canary
      backendRefs:
        - name: payments-v2
          port: 8080
    # Split live traffic: 90% stable (v1), 10% canary (v2)
    - matches:
        - path:
          type: PathPrefix
          value: /
      backendRefs:
        - name: payments-v1
          port: 8080
          weight: 90
        - name: payments-v2
          port: 8080
          weight: 10

2. Route-Level Rate Limiting

Protect downstream services from unexpected traffic surges without writing rate-limiting middleware in your application code. Envoy Gateway provides native Policy CRDs. For example, attach a BackendTrafficPolicy to throttle free-tier API callers to 100 requests per minute:

apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
  name: api-rate-limit
  namespace: default
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: payments-route
  rateLimit:
    global:
      rules:
        - clientSelectors:
            - headers:
                - name: X-User-Tier
                  value: free
          limit:
            requests: 100
            unit: Minute

3. Clean TLS Termination with cert-manager

Securing endpoints no longer requires messy ingress annotations. Point your cert-manager Certificate resource to write into a standard Secret, then reference it directly inside the Gateway listener:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: secure-gateway
  namespace: default
spec:
  gatewayClassName: eg
  listeners:
    - name: https
      protocol: HTTPS
      port: 443
      tls:
        mode: Terminate
        certificateRefs:
          - kind: Secret
            name: wildcard-example-tls

Field Notes: 6 Months Running Envoy Gateway in Production

During our migration, we processed roughly 45,000 requests per second across 14 namespaces. Envoy Gateway kept our median latency under 4 milliseconds, but getting there surfaced several operational lessons.

1. Lock Down Multi-Tenancy with ReferenceGrant

Security teams should isolate infrastructure from workload code. By default, Gateway API blocks cross-namespace bindings. If an HTTPRoute in the payments namespace tries to bind to a Gateway in the infra namespace, the controller rejects the route.

To grant explicit permission, create a ReferenceGrant inside the infra namespace:

apiVersion: gateway.networking.k8s.io/v1beta1
kind: ReferenceGrant
metadata:
  name: allow-routes-from-payments
  namespace: infra
spec:
  from:
    - group: gateway.networking.k8s.io
      kind: HTTPRoute
      namespace: payments
  to:
    - group: gateway.networking.k8s.io
      kind: Gateway

This pattern prevents unauthorized teams from hijacking public hostnames or routing external traffic to unauthorized services, which is essential when pairing with Kubernetes network policies to enforce defense-in-depth isolation.

2. Debug Status Conditions Instead of Grepping Logs

Stop sifting through gigabytes of controller logs when a deployment fails. The Gateway API standardizes resource status blocks. When a route misbehaves, run:

kubectl describe httproute payments-route

Scroll down to the Status.Parents section. Envoy Gateway populates structured conditions like Accepted: False or ResolvedRefs: False alongside clear diagnostic messages, such as "Service default/payments-v2 does not expose port 8080". You pinpoint errors in seconds, avoiding the need to inspect raw ingestion pipelines or rely on Kubernetes logging filters just to trace route reconciliation failures.

3. Size Your Data Plane and Configure Pod Disruption Budgets

Out of the box, Envoy Gateway deploys the Envoy data plane with modest resource requests (typically 100m CPU and 512Mi memory). For busy services, high connection churn can trigger out-of-memory kills.

Use the EnvoyProxy CRD to increase default CPU requests, pin horizontal pod autoscaling targets, and attach Pod Disruption Budgets (PDBs). When managing infrastructure and sizing requests and limits, having at least two healthy Envoy replicas ensures zero dropped connections when cloud nodes drain during automated cluster upgrades, especially on clusters running dynamic solutions like Karpenter.

Share: