1. Create a gateway resource with an HTTP listener.

      kubectl apply -f- <<EOF
    apiVersion: gateway.networking.k8s.io/v1
    kind: Gateway
    metadata:
      name: my-http-gateway
      namespace: gloo-system
      labels:
        example: httpbin-mydomain
    spec:
      gatewayClassName: gloo-gateway
      listeners:
      - protocol: HTTP
        port: 8080
        hostname: mydomain.com
        name: http
        allowedRoutes:
          namespaces:
            from: All
    EOF
      
    SettingDescription
    spec.gatewayClassNameThe name of the Kubernetes gateway class that you want to use to configure the gateway. When you set up Gloo Gateway, a default gateway class is set up for you. To view the gateway class configuration, see Gateway classes and types.
    spec.listenersConfigure the listeners for this gateway. In this example, you configure an HTTP gateway that listens for incoming traffic for the mydomain.com domain on port 8080. The gateway can serve HTTP routes from any namespace.
  2. Check the status of the gateway to make sure that your configuration is accepted and no conflicts exist in your cluster.

      kubectl get gateway my-http-gateway -n gloo-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-mydomain
      namespace: httpbin
      labels:
        example: httpbin-mydomain
    spec:
      parentRefs:
        - name: my-http-gateway
          namespace: gloo-system
      rules:
        - backendRefs:
            - name: httpbin
              port: 8000
    EOF
      
  4. Verify that the HTTPRoute is applied successfully.

      kubectl get httproute/httpbin-mydomain -n httpbin -o yaml
      
  5. Get the external address of the gateway and save it in an environment variable.

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

    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
      
  7. Optional: If you no longer need the HTTP listener, clean up the resources that you created.

      kubectl delete -A gateways,httproutes -l example=httpbin-mydomain