Static
Route requests to services that listen for incoming traffic on a fixed IP address and port or hostname and port combination by using static Upstreams.
You simply add the list of static hosts or DNS names to your Upstream resource and then reference the Upstream in your HTTPRoute resource. Unlike Upstreams that are dynamically created by using the discovery feature in Gloo Gateway, static Upstream resources must be created manually by the user.
Before you begin
Follow the Get started guide to install Gloo Gateway, set up a gateway resource, and deploy the httpbin sample app.
Get the external address of the gateway and save it in an environment variable.
Set up a static Upstream
Create a static Upstream resource that routes requests to the JSON testing API.
Create a RouteOption resource that rewrites the hostname to the
jsonplaceholder.typicode.com
.Create an HTTPRoute resource that routes traffic on the
static.example
domain to your Upstream resource. To ensure that your request can be forwarded to the JSON testing API, you must also reference the RouteOption resource that rewrites hostnames tojsonplaceholder.typicode.com
.Do not specify a port in thespec.backendRefs.port
field when referencing your Upstream. The port is defined in your Upstream resource and ignored if set on the HTTPRoute resource.Send a request to your Upstream and verify that you get back a 200 HTTP response code and a list of posts.
Example output:
Cleanup
You can optionally remove the resources that you created.