HTTP routing with the Gateway API
One entry point, routed by path.
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: b7dd271506c594a14e4bfbdae0c2a7ad85a6944a8f83d1761d165f4127d94eabA 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:
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
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.
# 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: v1kind: ConfigMapmetadata:name: web-confdata:default.conf: |server {listen 80;location / {default_type text/plain;return 200 "web: you asked for $request_uri\n";}}---apiVersion: v1kind: ConfigMapmetadata:name: api-confdata:default.conf: |server {listen 80;location / {default_type text/plain;return 200 "api: you asked for $request_uri\n";}}---apiVersion: apps/v1kind: Deploymentmetadata:name: webspec:replicas: 1selector:matchLabels:app: webtemplate:metadata:labels:app: webspec:containers:- name: nginximage: nginx:1.30.6-alpinevolumeMounts:- name: confmountPath: /etc/nginx/conf.dvolumes:- name: confconfigMap:name: web-conf---apiVersion: apps/v1kind: Deploymentmetadata:name: apispec:replicas: 1selector:matchLabels:app: apitemplate:metadata:labels:app: apispec:containers:- name: nginximage: nginx:1.30.6-alpinevolumeMounts:- name: confmountPath: /etc/nginx/conf.dvolumes:- name: confconfigMap:name: api-conf---apiVersion: v1kind: Servicemetadata:name: webspec:selector:app: webports:- port: 80---apiVersion: v1kind: Servicemetadata:name: apispec:selector:app: apiports:- port: 80
A Gateway
# kind has no cloud load balancer, so ask Envoy Gateway for a plain ClusterIP Service.apiVersion: gateway.envoyproxy.io/v1alpha1kind: EnvoyProxymetadata:name: clusteripnamespace: envoy-gateway-systemspec:provider:type: Kuberneteskubernetes:envoyService:type: ClusterIP---# Which controller runs Gateways of this class, and with which settings.apiVersion: gateway.networking.k8s.io/v1kind: GatewayClassmetadata:name: egspec:controllerName: gateway.envoyproxy.io/gatewayclass-controllerparametersRef:group: gateway.envoyproxy.iokind: EnvoyProxyname: clusteripnamespace: envoy-gateway-system---# One entry point that accepts plain HTTP on port 80.apiVersion: gateway.networking.k8s.io/v1kind: Gatewaymetadata:name: web-gwspec:gatewayClassName: eglisteners:- name: httpprotocol: HTTPport: 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.
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:
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.
# /api and everything below it goes to the api Service; all other paths go to web.apiVersion: gateway.networking.k8s.io/v1kind: HTTPRoutemetadata:name: web-routesspec:parentRefs:- name: web-gwrules:- matches:- path:type: PathPrefixvalue: /apibackendRefs:- name: apiport: 80- matches:- path:type: PathPrefixvalue: /backendRefs:- name: webport: 80
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:
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.
/ 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.
v1, as the CRD list showed with v1(storage).Accepted=True and ResolvedRefs=False (BackendNotFound). What does that tell you?/api/orders returned 500.PathPrefix /api. Which request does it NOT send to the api Service?/api and went to api./apiary went to web./api segment.