Changing GKE default domain to one usable for testing

By default, Cloud Run on GKE uses example.com as the base domain, where the fully qualified domain name for a service is formatted as http://{route}.{namespace}.example.com. This default domain doesn't work "out of the box" as a URL you can send requests to.

This page shows you how to change that default domain for your Cloud Run on GKE 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 alternatives 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 retrieve this IP address:

kubectl get service istio-ingressgateway --namespace istio-system

The command returns output similar to this:

NAME                   TYPE           CLUSTER-IP      EXTERNAL-IP
istio-ingressgateway   LoadBalancer   XX.XX.XXX.XXX   XX.XXX.XXX.XX

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 on GKE 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}.

Using a custom domain

If you want to use a custom domain that you own instead of 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}.

Was this page helpful? Let us know how we did:

Send feedback about...