HTTP routing with the Gateway API

One entry point, routed by path.

Beginner30 min · lesson 16 of 21
Lesson files
The scripts, test data and local test servers this lesson uses, exactly as they ran on the lab machine (4 files, 1 KB): ingress.tar.gz. The lab VM shares no folders with your computer, so fetch them inside the VM: cd ~/lab && curl -fsSLO https://secopslog.com/lab-files/k8s-fund/ingress.tar.gz && tar -xzf ingress.tar.gz, which creates ~/lab/ingress/. SHA-256: b7dd271506c594a14e4bfbdae0c2a7ad85a6944a8f83d1761d165f4127d94eab

A real web app is rarely one Service. The shop pages come from one and the API from another. You do not want a separate public address for each, and a cloud load balancer per Service gets expensive fast. What you want is one entry point that looks at each HTTP request and sends /api/... to the API and everything else to the website.

For years the answer was an Ingress object plus an Ingress controller, usually ingress-nginx. That has changed. The Kubernetes project announced that ingress-nginx would get only best-effort maintenance until March 2026 and then be retired, with no further releases or security fixes. The Ingress API itself stays in Kubernetes but is frozen, and the project now recommends its successor, the Gateway API.

Three objects, three jobs

The Gateway API splits the work into separate objects, so the people who run the cluster and the people who ship apps each own their part:

Gateway API objects
1GatewayClasswhich controller runs gateways2Gatewayan entry point: port 80, HTTP3HTTPRoutepath rules: /api and /4Servicesapi and web
A request enters through the Gateway; the HTTPRoute picks the Service.

Kubernetes itself ships none of these objects and no program that acts on them. You install an implementation. This lesson uses Envoy Gateway 1.10.0, the newest stable release in November 2026. Its install file contains the Gateway API object definitions (CRDs) as well as the controller.

Install Envoy Gateway

ubuntu@secopslog-k8s:~/lab/ingress · Kubernetes 1.37
$ kubectl apply --server-side -f https://github.com/envoyproxy/gateway/releases/download/v1.10.0/install.yaml
customresourcedefinition.apiextensions.k8s.io/backendtlspolicies.gateway.networking.k8s.io serverside-applied customresourcedefinition.apiextensions.k8s.io/gatewayclasses.gateway.networking.k8s.io serverside-applied customresourcedefinition.apiextensions.k8s.io/gateways.gateway.networking.k8s.io serverside-applied ... rolebinding.rbac.authorization.k8s.io/eg-gateway-helm-certgen serverside-applied job.batch/eg-gateway-helm-certgen serverside-applied mutatingwebhookconfiguration.admissionregistration.k8s.io/envoy-gateway-topology-injector.envoy-gateway-system serverside-applied
$ kubectl wait --timeout=5m -n envoy-gateway-system deployment/envoy-gateway --for=condition=Available
deployment.apps/envoy-gateway condition met
$ kubectl get crds | grep gateway.networking.k8s.io
backendtlspolicies.gateway.networking.k8s.io Namespaced v1(storage),v1alpha3 2026-11-11T08:39:30Z gatewayclasses.gateway.networking.k8s.io Cluster v1(storage),v1beta1 2026-11-11T08:39:30Z gateways.gateway.networking.k8s.io Namespaced v1(storage),v1beta1 2026-11-11T08:39:30Z grpcroutes.gateway.networking.k8s.io Namespaced v1(storage) 2026-11-11T08:39:30Z httproutes.gateway.networking.k8s.io Namespaced v1(storage),v1beta1 2026-11-11T08:39:30Z listenersets.gateway.networking.k8s.io Namespaced v1(storage) 2026-11-11T08:39:31Z referencegrants.gateway.networking.k8s.io Namespaced v1,v1beta1(storage) 2026-11-11T08:39:31Z tcproutes.gateway.networking.k8s.io Namespaced v1(storage),v1alpha2 2026-11-11T08:39:31Z tlsroutes.gateway.networking.k8s.io Namespaced v1(storage),v1alpha2,v1alpha3 2026-11-11T08:39:31Z udproutes.gateway.networking.k8s.io Namespaced v1(storage),v1alpha2 2026-11-11T08:39:31Z

The install printed one serverside-applied line per object, 41 of them; the middle is cut here. Most are CRDs, the rest are the controller, its permissions and a one-off job. --server-side is needed because some of the CRDs are too big for a normal kubectl apply. Once the envoy-gateway Deployment is available, the new object types exist: gatewayclasses, gateways and httproutes are the three this lesson uses. Note the v1(storage) in the main rows. These are stable APIs, not betas.

Two apps to route to

Two nginx Deployments, web and api, each with a Service. Each gets its nginx config from a ConfigMap, and the config simply answers every request with the app's name and the path it was asked for. That makes the routing easy to see.

apps.yaml
# Two small apps. Each nginx gets its config from a ConfigMap and answers every
# request with its own name and the path it was asked for.
apiVersion: v1
kind: ConfigMap
metadata:
name: web-conf
data:
default.conf: |
server {
listen 80;
location / {
default_type text/plain;
return 200 "web: you asked for $request_uri\n";
}
}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: api-conf
data:
default.conf: |
server {
listen 80;
location / {
default_type text/plain;
return 200 "api: you asked for $request_uri\n";
}
}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 1
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: nginx
image: nginx:1.30.6-alpine
volumeMounts:
- name: conf
mountPath: /etc/nginx/conf.d
volumes:
- name: conf
configMap:
name: web-conf
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
spec:
replicas: 1
selector:
matchLabels:
app: api
template:
metadata:
labels:
app: api
spec:
containers:
- name: nginx
image: nginx:1.30.6-alpine
volumeMounts:
- name: conf
mountPath: /etc/nginx/conf.d
volumes:
- name: conf
configMap:
name: api-conf
---
apiVersion: v1
kind: Service
metadata:
name: web
spec:
selector:
app: web
ports:
- port: 80
---
apiVersion: v1
kind: Service
metadata:
name: api
spec:
selector:
app: api
ports:
- port: 80
ubuntu@secopslog-k8s:~/lab/ingress · Kubernetes 1.37
$ kubectl apply -f apps.yaml && kubectl rollout status deployment/web && kubectl rollout status deployment/api
configmap/web-conf created configmap/api-conf created deployment.apps/web created deployment.apps/api created service/web created service/api created Waiting for deployment "web" rollout to finish: 0 of 1 updated replicas are available... deployment "web" successfully rolled out deployment "api" successfully rolled out

A Gateway

gateway.yaml
# kind has no cloud load balancer, so ask Envoy Gateway for a plain ClusterIP Service.
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyProxy
metadata:
name: clusterip
namespace: envoy-gateway-system
spec:
provider:
type: Kubernetes
kubernetes:
envoyService:
type: ClusterIP
---
# Which controller runs Gateways of this class, and with which settings.
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: eg
spec:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
parametersRef:
group: gateway.envoyproxy.io
kind: EnvoyProxy
name: clusterip
namespace: envoy-gateway-system
---
# One entry point that accepts plain HTTP on port 80.
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: web-gw
spec:
gatewayClassName: eg
listeners:
- name: http
protocol: HTTP
port: 80

The EnvoyProxy object is a kind-specific tweak. For every Gateway, Envoy Gateway starts Envoy Pods and puts a Service in front of them, by default of type LoadBalancer. Lesson 8 (Services) showed that such a Service stays <pending> on kind, and Envoy Gateway reports a Gateway without an address as not programmed (AddressNotAssigned). A plain ClusterIP Service avoids that. On a cloud cluster you would leave the default.

ubuntu@secopslog-k8s:~/lab/ingress · Kubernetes 1.37
$ kubectl apply -f gateway.yaml && kubectl wait --for=condition=Programmed gateway/web-gw --timeout=3m && kubectl get gatewayclass eg && kubectl get gateway web-gw
envoyproxy.gateway.envoyproxy.io/clusterip created gatewayclass.gateway.networking.k8s.io/eg created gateway.gateway.networking.k8s.io/web-gw created gateway.gateway.networking.k8s.io/web-gw condition met NAME CONTROLLER ACCEPTED AGE eg gateway.envoyproxy.io/gatewayclass-controller True 13s NAME CLASS ADDRESS PROGRAMMED AGE web-gw eg 10.96.216.110 True 13s

The GatewayClass eg is ACCEPTED: Envoy Gateway has taken charge of it. The Gateway web-gw is PROGRAMMED, which means the proxy is running and configured, and its ADDRESS is the cluster IP of the Envoy Service. Here is what Envoy Gateway started:

ubuntu@secopslog-k8s:~/lab/ingress · Kubernetes 1.37
$ kubectl get pods,services -n envoy-gateway-system
NAME READY STATUS RESTARTS AGE pod/eg-gateway-helm-certgen-j8d76 0/1 Completed 0 20s pod/envoy-default-web-gw-802cacc3-5f5bdc6c56-95vt8 2/2 Running 0 12s pod/envoy-gateway-7b99796d48-4d7dw 1/1 Running 0 20s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/envoy-default-web-gw-802cacc3 ClusterIP 10.96.216.110 <none> 80/TCP 12s service/envoy-gateway ClusterIP 10.96.207.131 <none> 18000/TCP,18001/TCP,18002/TCP,19001/TCP,9443/TCP 20s

envoy-gateway is the controller. The Pod named envoy-default-web-gw- plus a hash is the actual proxy for the Gateway web-gw in the namespace default, and the Service with the same name is its address. The certgen Pod is a one-off install job that has finished. The proxy Pod has two containers, Envoy and a small helper that shuts it down cleanly. Its Envoy image was downloaded from Docker Hub when the Gateway was created, which took about five seconds.

Routes

An HTTPRoute attaches to a Gateway with parentRefs and lists rules. A request goes to the rule with the most specific match, so the order in the file does not matter: /api wins over / for any path under /api.

route.yaml
# /api and everything below it goes to the api Service; all other paths go to web.
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: web-routes
spec:
parentRefs:
- name: web-gw
rules:
- matches:
- path:
type: PathPrefix
value: /api
backendRefs:
- name: api
port: 80
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: web
port: 80
ubuntu@secopslog-k8s:~/lab/ingress · Kubernetes 1.37
$ kubectl apply -f route.yaml
httproute.gateway.networking.k8s.io/web-routes created

Give it a few seconds, then read the route's status. An HTTPRoute has no READY column, so this command picks the conditions out with jsonpath:

ubuntu@secopslog-k8s:~/lab/ingress · Kubernetes 1.37
$ kubectl get httproute web-routes -o jsonpath='{range .status.parents[0].conditions[*]}{.type}={.status} ({.reason}){"\n"}{end}'
Accepted=True (Accepted) ResolvedRefs=True (ResolvedRefs)

Each line is one condition. Accepted=True means the Gateway took the route. ResolvedRefs=True means every Service the route names exists. Those two conditions are the first thing to check when a route does not work.

Send some requests

The Envoy Service is a ClusterIP, so from your machine you reach it with kubectl port-forward. One command block starts the forward in the background, sends four requests and stops it again. The first curl retries for a few seconds while the forward starts.

ubuntu@secopslog-k8s:~/lab/ingress · Kubernetes 1.37
$ SVC=$(kubectl get service -n envoy-gateway-system -l gateway.envoyproxy.io/owning-gateway-name=web-gw -o name) kubectl port-forward -n envoy-gateway-system "$SVC" 8080:80 >/dev/null & curl -s --retry 10 --retry-all-errors --retry-delay 1 -f http://localhost:8080/ curl -s http://localhost:8080/shop/cart curl -s http://localhost:8080/api/orders curl -s http://localhost:8080/apiary kill $!
web: you asked for / web: you asked for /shop/cart api: you asked for /api/orders web: you asked for /apiary

/ and /shop/cart went to web, /api/orders went to api. Look at the last line: /apiary went to web. A PathPrefix match works on whole path segments, so /api matches /api and /api/orders but not /apiary. A plain string prefix would have sent it to api.

Hands-on

Break the route on purpose, watch its status change, then mend it and remove everything.

1. Delete the api Service: kubectl delete service api.

2. Read the route conditions, repeating the command every few seconds until ResolvedRefs changes: kubectl get httproute web-routes -o jsonpath='{range .status.parents[0].conditions[*]}{.type}={.status} ({.reason}){"\n"}{end}'.

3. Port-forward again and print only the HTTP status codes: SVC=$(kubectl get service -n envoy-gateway-system -l gateway.envoyproxy.io/owning-gateway-name=web-gw -o name), then kubectl port-forward -n envoy-gateway-system "$SVC" 8080:80 >/dev/null &, then curl -s --retry 10 --retry-connrefused --retry-delay 1 -o /dev/null -w "/ -> %{http_code}\n" http://localhost:8080/ and curl -s -o /dev/null -w "/api/orders -> %{http_code}\n" http://localhost:8080/api/orders, and finally kill $! to stop the forward.

4. Put the Service back with kubectl expose deployment api --port=80 and run the command from step 2 again until ResolvedRefs=True.

5. Delete what you made: kubectl delete -f route.yaml -f gateway.yaml -f apps.yaml.

6. Uninstall Envoy Gateway by deleting its install file: kubectl delete --ignore-not-found -f https://github.com/envoyproxy/gateway/releases/download/v1.10.0/install.yaml. --ignore-not-found is needed because the install job deletes itself after it finishes, so one object in the file no longer exists.

7. Wait for its namespace to go, then list namespaces: kubectl wait --for=delete namespace/envoy-gateway-system --timeout=3m && kubectl get namespaces.

What you should see: in step 2 the route still says Accepted=True (Accepted), but ResolvedRefs=False (BackendNotFound). In step 3, / -> 200 while /api/orders -> 500: the rule whose Service exists still works, and Envoy has nowhere to send the other. Step 4 brings back ResolvedRefs=True. Step 6 prints a deleted line for each object, the Gateway API CRDs first. After step 7 the list holds only the namespaces kind started with, without envoy-gateway-system.

Remember

ingress-nginx is retired and the Ingress API is frozen, so new clusters route HTTP with the Gateway API and an implementation such as Envoy Gateway. A Gateway is the entry point, an HTTPRoute sends paths to Services, and its Accepted and ResolvedRefs conditions tell you whether the route was taken and whether its Services exist.

Quick check
01You are setting up HTTP routing on a new cluster in late 2026. Which choice matches what the Kubernetes project recommends?
Incorrect — ingress-nginx was retired after March 2026 and gets no more security fixes.
Incorrect — The core Gateway API objects are v1, as the CRD list showed with v1(storage).
Incorrect — That costs one load balancer per Service and still cannot route by path.
Correct — The Ingress API is frozen, and the project points new work to the Gateway API.
02An HTTPRoute shows Accepted=True and ResolvedRefs=False (BackendNotFound). What does that tell you?
Incorrect — Then Accepted would be False. Overlapping prefixes are normal; the most specific one wins.
Correct — Deleting the api Service in the hands-on gave exactly this, and /api/orders returned 500.
Incorrect — Without a controller nobody would write any status at all.
Incorrect — ResolvedRefs is about the backends the route names, not DNS.
03A rule matches PathPrefix /api. Which request does it NOT send to the api Service?
Incorrect — This matches the prefix exactly.
Incorrect — This sits under /api and went to api.
Correct — Prefixes match whole path segments, and /apiary went to web.
Incorrect — A trailing slash still sits under the /api segment.

Related