Using a testing domain

By default, Cloud Run for Anthos on Google Cloud uses example.com as the base domain, where the fully qualified domain name for a service is formatted as http://{service}.{namespace}.example.com. Note that this URL does not accept requests.

This page shows you how to change that default domain for your Cloud Run for Anthos cluster to a domain usable for testing purposes. The instructions show the use of free DNS wildcard sites so you don't have to purchase a custom domain for testing. However, you can also use wildcards with a custom domain that you own if you wish. This page shows both methods.

Before you begin

Make sure you have installed and configured Cloud SDK and kubectl.

Choose an alternative for wildcard DNS

When you are developing and testing, you change the default domain to use one of the free wildcard DNS test sites. Examples include:

Instead of using one of these free sites, you can alternatively change the default domain to a custom domain that you own, which involves buying a domain and setting up records at your domain registrar to support DNS wildcards.

Getting the external IP address

Whether you use one of the free wildcard DNS sites or a custom domain that you own, you need to obtain the external IP address of the Load Balancer service created for the Istio ingress controller.

To get the external IP for the Istio ingress gateway:

kubectl get svc ISTIO-GATEWAY -n NAMESPACE 
Replace ISTIO-GATEWAY and NAMESPACE as follows:
Cluster version ISTIO-GATEWAY NAMESPACE
1.15.3-gke.19 and greater
1.14.3-gke.12 and greater
1.13.10-gke.8 and greater
istio-ingress gke-system
All other versions istio-ingressgateway istio-system

where the resulting output looks something like this:

NAME            TYPE           CLUSTER-IP     EXTERNAL-IP  PORT(S)
ISTIO-GATEWAY    LoadBalancer   XX.XX.XXX.XX   pending     80:32380/TCP,443:32390/TCP,32400:32400/TCP

The EXTERNAL-IP for the Load Balancer is the IP address you must use.

  • For the free wildcard sites, you'll use the external IP address when you edit the cluster configuration, which is described next.
  • For a custom domain that you own, you won't use the external IP address in the cluster configuration, but you will use it in a new or updated record at your domain registrar.

Editing cluster domain configuration

Cloud Run for Anthos uses the config-domain ConfigMap to define the base domain for all services deployed to the cluster. The command to edit this configuration will vary depending on whether you use a free wildcard DNS site or a custom domain that you own.

Using free DNS wildcard sites

To change the default base domain from example.com to one of the free DNS wildcard sites, for example, xip.io, use the command:

kubectl patch configmap config-domain --namespace knative-serving --patch \
  '{"data": {"example.com": null, "[EXTERNAL-IP].xip.io": ""}}'

Replace

  • [EXTERNAL-IP] with the Load Balancer external IP address.
  • xip.io with whatever free wildcard DNS site you are using.

You can repeat this command with different values if you want to change this again.

Your services will now be available at {service-name}.{namespace}.{[EXTERNAL-IP].xip.io}.

Testing with a custom domain

If you want to use a custom domain that you own, in order to test using that domain, instead of using one of the free wildcard DNS sites:

  1. Specify your custom domain using the command:

    kubectl patch configmap config-domain --namespace knative-serving --patch \
    '{"data": {"example.com": null, "[DOMAIN]": ""}}'

    Replace [DOMAIN] with your own domain, for example, mydomain.com The command above removes example.com from the ConfigMap and adds mydomain.com as the default base domain. You can repeat this command if you want to change this again to some other domain.

  2. Log in to your account at your domain registrar and then open the DNS configuration page.

  3. Locate the host records section of your domain's configuration page and then add the resource records you need

    1. To add a DNS record to the account at the DNS provider:

      • Select the record type A.
      • Supply the wildcard *, as shown in the following example:

        dns wildcard

    2. Save your changes in the DNS configuration page of your domain's account. In most cases, it takes only a few minutes for these changes to take effect, but in some cases it can take up several hours, depending on the registrar, and on the Time-To-Live (TTL) of any previous DNS records for your domain.

After updating your DNS records and pointing them to your cluster, your services will be available at {service-name}.{namespace}.{your-domain}.