Configuring DNS on the cloud.goog domain

After your API is deployed, users of your API need to access it through a domain name rather than an IP address. You can either:

  • Configure .endpoints.PROJECT_ID.cloud.goog as the domain name (where PROJECT_ID is your Google Cloud project ID).
  • Or register your own domain name, such as example.com, which entails:
    • Configuring DNS name servers (or using Cloud DNS).
    • Updating registry addresses.
    • Creating and maintaining DNS records.

    If you already have a DNS infrastructure, or you want to register your own domain name, see Serving an API from your domain name for more information.

This page describes how to configure Cloud Endpoints APIs to use .endpoints.PROJECT_ID.cloud.goog as the domain name. The configuration steps on this page are applicable for APIs using gRPC running on Compute Engine, Google Kubernetes Engine, or Kubernetes.

The .cloud.goog domain is managed by Google and shared by Google Cloud customers. Because Google Cloud projects are guaranteed to have a globally unique project ID, a domain name in the format .endpoints.PROJECT_ID.cloud.goog is unique and can be used as the domain name for your API. Configuring the .endpoints.PROJECT_ID.cloud.goog domain name is optional. If you prefer, you can register your own domain name.

Prerequisites

As a starting point, this page assumes that you have already created your Cloud Endpoints API and deployed it to Compute Engine, Google Kubernetes Engine, or Kubernetes. If you need an API for testing, you can use one of the tutorials that walk you through configuring and deploying a sample API.

Configuring DNS

The following procedure describes how to configure DNS for Endpoints APIs that use .endpoints.PROJECT_ID.cloud.goog as the Endpoints service name. For convenience, the procedure refers to your gRPC service configuration file as service.yaml.

To configure DNS:

  1. Open service.yaml, and add the endpoints field to the file as shown in the following code snippet:
    type: google.api.Service
    name: API_NAME.endpoints.PROJECT_ID.cloud.goog
    endpoints:
    - name: API_NAME.endpoints.PROJECT_ID.cloud.goog
      target: "IP_ADDRESS"
      

    Typically, the name field and the endpoints.name field are the same.

  2. Replace API_NAME with the name of your API (for example, bookstore or my-cool-api).
  3. Replace IP_ADDRESS with an IPv4 address. The IP address is a string and must be enclosed in quotation marks.

    For example, if you deploy your Endpoints API service to a Compute Engine virtual machine instance, you can use the external IP address of that virtual machine. Alternatively, if you run your code on a group of virtual machine instances (or GKE pods) behind a load balancer, you can use the IP address of the load balancer.

  4. Deploy your updated gRPC configuration file to Service Management by using the following command:
    gcloud endpoints services deploy service.yaml service.pb
    

For example, if the following is specified in the service.yaml file:

type: google.api.Service
name: my-cool-api.endpoints.my-project-id.cloud.goog
endpoints:
- name: my-cool-api.endpoints.my-project-id.cloud.goog
  target: "192.0.2.1"

When you deploy the service.yaml file by using the precediing gcloud command, Service Management creates a DNS A-record, my-cool-api.endpoints.my-project-id.cloud.goog, which resolves to the target IP address, 192.0.2.1. You might need to wait a few minutes for the new DNS configuration to propagate.

What's next