Ingress with custom domain

- By: Thomas Jungbauer ( Lastmod: 2021-08-14 ) - 2 min read

Since Service Mesh 1.1, there is a better way to achieve the following. Especially the manual creation of the route is not required anymore. Check the following article to Enable Automatic Route Creation.

Often the question is how to get traffic into the Service Mesh when using a custom domains. Part 4 our our tutorials series OpenShift 4 and Service Mesh will use a dummy domain "" and explains the required settings which must be done.

Modify Gateway and VirtualService

Issue #3 explains how to get ingress traffic into the Service Mesh, by defining the Gateway and the VirtualService. We are currently using the default ingress route defined in the istio_system project.
But what if a custom domain shall be used?
In such case another route must be defined in the istio-system project and small configuration changes must be applied.

  1. First lets create a slightly modified Gateway.yaml:

    kind: Gateway
      name: ingress-gateway-exampleapp
        istio: ingressgateway # use istio default controller
      - port:
          number: 80
          name: http
          protocol: HTTP
        - "" (1)
    1add you custom domain here

    The only difference is at the hosts which was changed from '*' to ''

  2. As second change, the VirtualService must be modified as well with the custom domain:


    kind: VirtualService
      name: ingress-gateway-exampleapp
      - "" (1)
      - ingress-gateway-exampleapp
      - match:
        - uri:
            exact: /
        - destination:
            host: customer
              number: 8080
    1add you custom domain here
  3. Replace current objects in OpenShift:

    oc replace -f Gateway.yaml -n tutorial
    oc replace -f VirtualService.yaml -n tutorial
  4. Create a new route under the project istio-system:

    kind: Route
      name: (1)
      namespace: istio-system (2)
      host: (3)
        kind: Service
        name: istio-ingressgateway (4)
        targetPort: 8080
    1add you custom domain here
    2the route must be created at istio-system
    3add you custom domain here
    4this is the service as it was created by the operator

OPTIONAL: Add custom domain to local hosts file

The custom domain must be resolvable somehow, pointing to the ingress router of OpenShift. This can be done, by adding the domain into the local hosts file (with all limitations this brings with it)

# Get IP address of:
oc -n istio-system get route istio-ingressgateway
echo "x.x.x.x" >> /etc/hosts

Create some example traffic

We will reuse the script of Issue #3 to simulate traffic. Since we changed the domain, the connection will go to

sh 1000

This will send 1000 requests to our application:

# 0: customer => preference => recommendation v1 from 'f11b097f1dd0': 6626
# 1: customer => preference => recommendation v1 from 'f11b097f1dd0': 6627
# 2: customer => preference => recommendation v1 from 'f11b097f1dd0': 6628
# 3: customer => preference => recommendation v1 from 'f11b097f1dd0': 6629
# 4: customer => preference => recommendation v1 from 'f11b097f1dd0': 6630
# 5: customer => preference => recommendation v1 from 'f11b097f1dd0': 6631