This page describes how to configure DNS for Google Endpoints services using the
.endpoints.project-id.cloud.goog domain name. The configuration steps on this
page are applicable for APIs using gRPC and running on a Google Compute Engine
or Google Container Engine instance.
.cloud.goog domain is managed by Google and shared by Google Cloud
customers. Because Cloud Platform Console projects are guaranteed to have a
globally unique name, a domain name in the
.endpoints.[PROJECT_ID].cloud.goog will be unique and can be used as the
domain name in the URL for your API.
.endpoints.[PROJECT_ID].cloud.goog domain name is optional.
Configuring DNS for an API on Compute Engine of Container Engine
After your API is up and running on Compute Engine or Container Engine, you will want the users of your API to access the API through a domain name rather than an IP address. You can either:
- Configure the
.endpoints.[PROJECT_ID].cloud.googas the domain name, as described in the following procedure, To configure DNS for Compute Engine or Container Engine.
Or register your own domain name (for example,
my-company.com), which entails:
- Configuring DNS name servers (or using Google 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.
To configure DNS for Compute Engine or Container Engine
- Open your gRPC API configuration file (
service.yaml), and add the
endpointsfield to the file as shown in the following 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]"
Note that the
namefield and the
endpoints.namefield should be the same.
[API_NAME]with the name of your API (for example,
- Replace the
[PROJECT_ID]with your Cloud project ID.
- Replace the
[IP_ADDRESS]with an IPv4 address. Note that 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 of that virtual machine. Alternatively, if you run your code on a group of virtual machine instances (or Container Engine pods) behind a load balancer, you can use the IP address of the load balancer.
- Deploy your updated gRPC configuration file to Service Management using
the following command:
gcloud service-management deploy service.yaml service.pb
For example, if the following is specified in the
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 using the above
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.