This article demonstrates working with Istio Gateways, including configuration, deployment, and testing processes for specific hostnames.
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.
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.
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:
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.
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:
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:
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:
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:
Copy
Ask AI
echo -e "$(minikube ip)\tbookinfo.app" | sudo tee -a /etc/hosts
Next, open your browser and navigate to:
Copy
Ask AI
http://bookinfo.app:<PORT>/productpage
Replace <PORT> with your actual ingress port. You should see the Bookinfo product page load correctly.
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:
Copy
Ask AI
echo -e "$(minikube ip) bookinfo.app" | sudo tee -a /etc/hosts
Then, update the Gateway to use the wildcard ”*” for hosts:
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!