*.example.com, and attach an HTTPRoute so external requests reach the app.

Application and Service
This demo uses a simple “coffee” application deployed as a Deployment and exposed via a ClusterIP Service namedcoffee.
Key Service details:
- Service name:
coffee - Service port:
80 - Target container port:
8080 - Protocol:
TCP - Service port name:
http
Gateway manifest
Create a Gateway to accept HTTP on port 80. The Gateway references aGatewayClass (nginx) so the underlying implementation (control plane + data plane) knows which controller to use. The listener restricts hostnames to *.example.com, allowing routes to match subdomains such as cafe.example.com.
gateway-nginx-...) that receives translated configuration from the Gateway API control plane. Wait for that pod to reach Running before testing.
The Gateway’s
hostname (for example *.example.com) limits which Host header / SNI values are accepted. Routes (HTTPRoute) that target a specific hostname like cafe.example.com must match a hostname allowed by the Gateway.HTTPRoute manifest
Create an HTTPRoute that binds to thegateway listener (section http) and routes requests with the /coffee path prefix to the coffee Service on port 80.
Testing with curl
In a local lab environment we often don’t have real DNS forcafe.example.com, so we use curl --resolve to override DNS and send the correct Host header. You can reach the Gateway either by port-forwarding the Gateway service to localhost or by hitting the NodePort exposed by the Gateway.
Port-forward example (forward service port 80 to local 8080):
/coffee path while preserving the Host header:
kubectl get svc (31437 in the example):
cafe.example.com and route /coffee to the coffee Service.
Successful request example (same curl command as above):
/coffee123), the Gateway proxy returns a 404:
Quick resource summary
Summary
- Deployed the
coffeeapplication and exposed it via a ClusterIP Service. - Created a Gateway that listens on HTTP port 80 and accepts
*.example.com. - Attached an HTTPRoute for
cafe.example.comand routed/coffeerequests to thecoffeeService. - Tested end-to-end routing locally with
curl --resolve(or via NodePort / port-forward).
- Gateway API: https://gateway-api.sigs.k8s.io/
- Kubernetes documentation: https://kubernetes.io/docs/
- NGINX documentation: https://docs.nginx.com/