Set up a 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.

    kubectl apply -f- <<EOF
    kind: Gateway
    apiVersion: gateway.networking.k8s.io/v1
    metadata:
      name: http
      namespace: kgateway-system
    spec:
      gatewayClassName: kgateway
      listeners:
      - protocol: HTTP
        port: 8080
        name: http
        allowedRoutes:
          namespaces:
            from: All
    EOF
  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 kgateway-system

    Example output:

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

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

    Example output:

    NAME                  READY   STATUS    RESTARTS   AGE
    http-7dd94b74-k26j6   1/1     Running   0          18s
    ℹ️
    Using Kind and getting a CrashLoopBackOff error with a Failed to create temporary file message in the logs? You might have a multi-arch platform issue on macOS. In your Docker Desktop settings, uncheck Use Rosetta, restart Docker, re-create your Kind cluster, and try again.

Next

Deploy the httpbin sample app and start routing traffic to the app. You can use this app to try out other traffic management, resiliency, and security guides in this documentation.

Other configuration examples

Review other common configuration examples for your Gateway. To customize your Gateway even further, such as with Kubernetes overlays, check out Customize the proxy.

Static IP address

You can assign a static IP address to the service that exposes your gateway proxy by using the spec.addresses field.

kind: Gateway
apiVersion: gateway.networking.k8s.io/v1
metadata:
  name: http
  namespace: kgateway-system
spec:
  gatewayClassName: kgateway
  addresses:
    - type: IPAddress
      value: 203.0.113.11
  listeners:
    - protocol: HTTP
      port: 80
      name: http
      allowedRoutes:
        namespaces:
          from: Same