Skip to main content
In this guide, we demonstrate how to work with Istio Gateways—starting with a preconfigured Gateway and then creating one that listens for a specific hostname. This article is designed to be SEO friendly and provides a step-by-step explanation, including configuration, deployment, and testing processes.

Reviewing the Preconfigured Gateway

First, let’s examine the existing Gateway configuration from our samples folder. Notice that this configuration uses a wildcard ”*” for the host value. This allows the Gateway to accept traffic from any host.
Ensure that you understand how wildcard hosts affect traffic routing in Istio before proceeding.

Deploying the Bookinfo Application

Before configuring a new Gateway with a specific hostname, verify that all required applications are running. Deploy the Bookinfo application using the provided YAML configuration:
You should see output similar to the following:

Creating a Gateway with a Specific Hostname

Next, we create a Gateway that listens specifically for requests targeting the hostname “bookinfo.app”. This configuration accepts HTTP traffic on port 80 directed to that host.
After running the command, the output should confirm the creation similar to:

Configuring the Virtual Service

For the Gateway configuration to work as intended, you need to define a Virtual Service that routes incoming requests to the correct service based on specific URI match rules. It is crucial that the hosts defined in the Virtual Service match those in the Gateway. Apply the Virtual Service configuration with the command below:
The command should output:
Ensure that the hosts in your Gateway and Virtual Service configurations match exactly for proper routing.

Testing the Configuration

To confirm the Gateway correctly handles traffic, include the header “Host: bookinfo.app” when sending your requests. For example, to test the configuration using curl, run:
Next, test accessing the product page:
The expected output should display HTML content similar to:
Always include the appropriate Host header in your requests to ensure they are routed correctly through the Istio Gateway.

Verifying in Kiali

Kiali provides a graphical view of your Istio configuration. You can confirm your Gateway settings by checking the Istio config section in Kiali. Below is an example of how your Gateway configuration might appear in Kiali:

Accessing the Application via a Browser

To test your configuration in a web browser, update your local hosts file so that “bookinfo.app” resolves to your cluster’s IP address. For example, if you are using Minikube, execute:
Next, open your browser and navigate to:
Replace <PORT> with your actual ingress port. You should see the Bookinfo product page load correctly.

Reverting Back to Wildcard Hostname

If you need to revert to the default gateway configuration using a wildcard hostname (especially during training), update your Gateway configuration. First, ensure your hosts file is correct:
Then, update the Gateway to use the wildcard ”*” for hosts:
If your Virtual Service configuration also needs to revert to a wildcard hostname, update it accordingly:
Using these steps, you can easily switch between a specific hostname and a wildcard configuration, ensuring that the Bookinfo application remains accessible under both scenarios. Happy configuring and exploring the powerful routing capabilities of Istio!

Watch Video