For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
Host
Verified Code examples on this page have been automatically tested and verified.Expose a route on multiple hosts.
For more information, see the Kubernetes Gateway API documentation.
Before you begin
- Set up an agentgateway proxy.
- Install the httpbin sample app.
Set up host matching
Create an HTTPRoute that is exposed on two domains,
host1.exampleandhost2.example.kubectl apply -f- <<EOF apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: httpbin-match namespace: httpbin spec: parentRefs: - name: agentgateway-proxy namespace: agentgateway-system hostnames: - host1.example - host2.example rules: - backendRefs: - name: httpbin port: 8000 EOFSend a request to the
/status/200path of the httpbin app on thehost1.exampledomain. Verify that you get back a 200 HTTP response code.curl -vi http://$INGRESS_GW_ADDRESS:80/status/200 -H "host: host1.example"Example output:
* Request completely sent off < HTTP/1.1 200 OK HTTP/1.1 200 OK < access-control-allow-credentials: true access-control-allow-credentials: true < access-control-allow-origin: * access-control-allow-origin: * < content-length: 0 content-length: 0Send another request to the httpbin app. This time, you send it along the
host2.exampledomain. Verify that the request succeeds and that you also get back a 200 HTTP response code.curl -vi http://$INGRESS_GW_ADDRESS:80/status/200 -H "host: host2.example"Example output:
* Request completely sent off < HTTP/1.1 200 OK HTTP/1.1 200 OK < access-control-allow-credentials: true access-control-allow-credentials: true < access-control-allow-origin: * access-control-allow-origin: * < content-length: 0 content-length: 0
Cleanup
You can remove the resources that you created in this guide.kubectl delete httproute httpbin-match -n httpbin