Skip to content

HTTP

Create an HTTP listener on your gateway proxy. Your proxy listens for HTTP traffic on the specified port and hostname that you configure.

Before you begin

Deploy the httpbin sample app.

Set up an HTTP listener

Set up an HTTP listener on your Gateway.

  1. Create a Gateway resource with an HTTP listener.

    kubectl apply -f- <<EOF
    apiVersion: gateway.networking.k8s.io/v1
    kind: Gateway
    metadata:
      name: agentgateway-proxy-http
      namespace: agentgateway-system
    spec:
      gatewayClassName: agentgateway
      listeners:
      - protocol: HTTP
        port: 80
        name: http
        allowedRoutes:
          namespaces:
            from: All
    EOF

    Review the following table to understand this configuration.

    SettingDescription
    spec.gatewayClassNameThe name of the Kubernetes GatewayClass that you want to use to configure the Gateway. When you set up agentgateway, a default GatewayClass is set up for you.
    spec.listenersConfigure the listeners for this Gateway. In this example, you configure an HTTP Gateway that listens for incoming traffic on port 80. The Gateway can serve HTTPRoutes from any namespace.
  2. Check the status of the Gateway to make sure that your configuration is accepted. Note that in the output, a NoConflicts status of False indicates that the Gateway is accepted and does not conflict with other Gateway configuration.

    kubectl get gateway agentgateway-proxy-http -n agentgateway-system -o yaml
  3. Create an HTTPRoute resource for the httpbin app that is served by the Gateway that you created.

    kubectl apply -f- <<EOF
    apiVersion: gateway.networking.k8s.io/v1
    kind: HTTPRoute
    metadata:
      name: httpbin-route
      namespace: httpbin
    spec:
      hostnames:
      - listener.example
      parentRefs:
        - name: agentgateway-proxy-http
          namespace: agentgateway-system
      rules:
        - backendRefs:
            - name: httpbin
              port: 8000
    EOF
  1. Verify that the HTTPRoute is applied successfully.

    kubectl get httproute/httpbin-route -n httpbin -o yaml

    Example output: Notice in the status section that the parentRef is either the Gateway or the ListenerSet, depending on how you attached the HTTPRoute.

    ...
    status:
      parents:
      - conditions:
        ...
        parentRef:
          group: gateway.networking.k8s.io
          kind: Gateway
          name: agentgateway-proxy-http
          namespace: agentgateway-system
  2. Verify that the listener now has a route attached.

    kubectl get gateway -n agentgateway-system agentgateway-proxy-http -o yaml

    Example output:

    ...
    listeners:
    - attachedRoutes: 1
  3. Get the external address of the gateway and save it in an environment variable.

    export INGRESS_GW_ADDRESS=$(kubectl get svc -n agentgateway-system agentgateway-proxy-http -o jsonpath="{.status.loadBalancer.ingress[0]['hostname','ip']}")
    echo $INGRESS_GW_ADDRESS   

  4. Send a request to the httpbin app and verify that you get back a 200 HTTP response code.

    curl -vi http://$INGRESS_GW_ADDRESS:80/status/200 -H "host: listener.example" 

    Example output:

    * Mark bundle as not supporting multiuse
    < 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: *
    < date: Fri, 03 Nov 2023 20:02:48 GMT
    date: Fri, 03 Nov 2023 20:02:48 GMT
    < content-length: 0
    content-length: 0
    < x-envoy-upstream-service-time: 1
    x-envoy-upstream-service-time: 1
    < server: envoy
    server: envoy
    

Cleanup

You can remove the resources that you created in this guide.
kubectl delete gateway agentgateway-proxy-http -n agentgateway-system
kubectl delete httproute httpbin-route -n httpbin
Was this page helpful?
Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.