Create an HTTP listener on your API Gateway. Then, your API Gateway listens for HTTP traffic on the specified port and hostname that you configure. This Gateway can be used as the main ingress for the apps in your cluster. You can also create multiple Gateways to listen for traffic on different ports and hostnames.
Next, you set up an HTTPRoute resource to route requests through the Gateway to backing services in your cluster. HTTPRoutes can refer to any gateway independent of the namespace they are in.
Decide whether to set up a listener inline on the Gateway resource or as a separate ListenerSet resource. For more information, see the Listener overview.
ListenerSets: This feature is available with Gloo Gateway 2.x or later. Also, you must install the experimental channel of the Kubernetes Gateway API at version 1.3 or later.
If you plan to set up your listener as part of a ListenerSet, keep the following considerations in mind. For more information, see ListenerSets (experimental).
This feature is available with Gloo Gateway 2.x or later.
You must install the experimental channel of the Kubernetes Gateway API at version 1.3 or later.
Review the following table to understand this configuration.
Setting
Description
spec.gatewayClassName
The name of the Kubernetes GatewayClass that you want to use to configure the Gateway. When you set up Gloo Gateway, a default GatewayClass is set up for you.
spec.listeners
Configure 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.
Create a Gateway that enables the attachment of ListenerSets.
Review the following table to understand this configuration.
Setting
Description
spec.gatewayClassName
The name of the Kubernetes GatewayClass that you want to use to configure the Gateway. When you set up Gloo Gateway, a default GatewayClass is set up for you.
spec.allowedListeners
Enable the attachment of ListenerSets to this Gateway. The example allows listeners from any namespace, which is helpful in multitenant environments. You can also limit the allowed listeners. To limit to listeners in the same namespace as the Gateway, set this value to Same. To limit to listeners with a particular label, set this value to Selector.
spec.listeners
Optionally, you can configure a listener that is specific to the Gateway. Note that due to a Gateway API limitation, you must configure at least one listener on the Gateway resource, even if the listener is not used and is a generic, “dummy” listener. This generic listener cannot conflict with the listener that you configure in the ListenerSet, such as using the same port or name. In this example, the generic listener is configured on port 80, which differs from port 8080 in the ListenerSet that you create later.
Create a ListenerSet that configures an HTTP listener for the Gateway.
Review the following table to understand this configuration.
Setting
Description
spec.parentRef
The name of the Gateway to attach the ListenerSet to.
spec.listeners
Configure the listeners for this ListenerSet. 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.
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 my-http-gateway -n gloo-system -o yaml
Create an HTTPRoute resource for the httpbin app that is served by the Gateway that you created.
Verify that the listener now has a route attached.
kubectl get gateway -n gloo-system my-http-gateway -o yaml
Example output:
...
listeners:
- attachedRoutes: 1
kubectl get xlistenerset -n httpbin my-http-listenerset -o yaml
Example output:
...
listeners:
- attachedRoutes: 1
Note that because the HTTPRoute is attached to the ListenerSet, the Gateway does not show the route in its status.
kubectl get gateway -n gloo-system my-http-gateway -o yaml
Example output:
...
listeners:
- attachedRoutes: 0
If you create another HTTPRoute that attaches to the Gateway and uses the same listener as the ListenerSet, then the route is reported in the status of both the Gateway (attachedRoutes: 1) and the ListenerSet (attachedRoutes: 2).
Get the external address of the gateway and save it in an environment variable.