The httpbin app lets you test your API gateway by sending requests to it and receiving responses.

Review the following diagram to understand the setup.

flowchart LR
    A[client] -->|example.com| B[gateway proxy]
    B --> C[httpbin backend]
  • The client calls the www.example.com hostname that you set up in the Gateway configuration.
  • The gateway proxy receives the request. Based on the routing rules that you set up in the Gateway configuration, the gateway proxy forwards the traffic to the backend destination, which is the httpbin service. The gateway proxy is available from an external LoadBalancer service that is backed by an IP address that your cloud provider typically assigns. For testing in a local cluster where you do not have an external service, you can enable port-forwarding so that the gateway proxy listens on the localhost instead.
  • The httpbin service receives and responds to the request. Note that the httpbin service does not have to be publicly exposed because the gateway proxy handles the external traffic. Instead, it can have an internal service type, such as ClusterIP.

Before you begin

Set up Gloo Gateway by following the Quick start or Installation guides.

Deploy a sample app

The following configuration file creates the httpbin app. To review the source file, see the kgateway project.

  1. Create the httpbin app.

      kubectl apply -f https://raw.githubusercontent.com/kgateway-dev/kgateway/refs/heads/v2.0.x/examples/httpbin.yaml
      

    Example output:

      namespace/httpbin created
    serviceaccount/httpbin created
    service/httpbin created
    deployment.apps/httpbin created
      
  2. Verify that the httpbin app is running.

      kubectl -n httpbin get pods
      

    Example output:

      NAME                      READY   STATUS    RESTARTS   AGE
    httpbin-d57c95548-nz98t   2/2     Running   0          18s
      

Set up an API gateway

Create an API gateway with an HTTP listener by using the Kubernetes Gateway API.

  1. Create a Gateway resource and configure an HTTP listener. The following Gateway can serve HTTPRoute resources from all namespaces. For more information about which GatewayClass to use, see About gateway proxies.

  2. Verify that the Gateway is created successfully. You can also review the external address that is assigned to the Gateway. Note that depending on your environment it might take a few minutes for the load balancer service to be assigned an external address. If you are using a local Kind cluster without a load balancer such as metallb, you might not have an external address.

      kubectl get gateway http -n gloo-system
      

    Example output:

      NAME   CLASS      ADDRESS                                  PROGRAMMED   AGE
    http   gloo-gateway-v2   1234567890.us-east-2.elb.amazonaws.com   True         93s
      
  3. Verify that the gateway proxy pod is running.

      kubectl get po -n gloo-system -l gateway.networking.k8s.io/gateway-name=http
      

    Example output:

      NAME                  READY   STATUS    RESTARTS   AGE
    http-7dd94b74-k26j6   3/3     Running   0          18s
      

Expose the app on the gateway

Now that you have an app and a gateway proxy, you can create a route to access the app.

  1. Create an HTTPRoute resource to expose the httpbin app on the Gateway. The following example exposes the app on the wwww.example.com domain.

      kubectl apply -f- <<EOF
    apiVersion: gateway.networking.k8s.io/v1
    kind: HTTPRoute
    metadata:
      name: httpbin
      namespace: httpbin
    spec:
      parentRefs:
        - name: http
          namespace: gloo-system
      hostnames:
        - "www.example.com"
      rules:
        - backendRefs:
            - name: httpbin
              port: 8000
    EOF
      
    SettingDescription
    spec.parentRefsThe name and namespace of the Gateway resource that serves the route. In this example, you use the http Gateway that you created earlier.
    spec.hostnamesA list of hostnames that the route is exposed on. In the example, the route is exposed on www.example.com.
    spec.rules.backendRefsThe Kubernetes service that serves the incoming request. In this example, requests to www.example.com are forwarded to the httpbin app on port 8000. Note that you must create the HTTPRoute in the same namespace as the service that serves that route. To create the HTTPRoute resource in a different namespace, you must create a ReferenceGrant resource to allow the HTTPRoute to forward requests to a service in a different namespace. For more information, see the Kubernetes API Gateway documentation.
  2. Verify that the HTTPRoute is applied successfully.

      kubectl get -n httpbin httproute/httpbin -o yaml
      

    Example output: Note the status of the HTTPRoute resource. Check for Accepted and ResolvedRefs messages. The parentRef refers to the Gateway that that HTTPRoute is exposed on.

      status:
      parents:
      - conditions:
        - lastTransitionTime: "2025-02-13T18:41:06Z"
          message: ""
          observedGeneration: 1
          reason: Accepted
          status: "True"
          type: Accepted
        - lastTransitionTime: "2025-02-13T18:41:06Z"
          message: ""
          observedGeneration: 1
          reason: ResolvedRefs
          status: "True"
          type: ResolvedRefs
        controllerName: kgateway.dev/kgateway
        parentRef:
          group: gateway.networking.k8s.io
          kind: Gateway
          name: http
          namespace: gloo-system
      

Send a request

Now that your httpbin app is running and exposed on the gateway proxy, you can send a request to the app. The steps vary depending on your load balancer setup.

Next steps

Now that you have Gloo Gateway set up and running, check out the following guides to expand your API gateway capabilities.

  • Add routing capabilities to your httpbin route by using the Traffic management guides.
  • Explore ways to make your routes more resilient by using the Resiliency guides.
  • Secure your routes with external authentication and rate limiting policies by using the Security guides.

Cleanup

You can remove the resources that you created in this guide.
  1. Delete the httpbin app.

      kubectl delete -f https://raw.githubusercontent.com/kgateway-dev/kgateway/refs/heads/v2.0.x/examples/httpbin.yaml
      
  2. Delete the HTTPRoute.

      kubectl delete httproute httpbin -n httpbin
      
  3. Delete the Gateway.

      kubectl delete gateway http -n gloo-system