After you have configured your protobuf descriptor file and gRPC API configuration file, you deploy them so that Cloud Endpoints has the information that it needs to manage your API. To deploy the Endpoints configuration, you use the gcloud endpoints services deploy command. This command uses Google Service Management, an infrastructure service of GCP that manages other APIs and services, including services created using Cloud Endpoints. This page describes how to deploy your configuration files to Cloud Endpoints.
As a starting point, this page assumes that you have:
- Created a Google Cloud Platform (GCP) project in which you have the Editor or Owner role. See Controlling API Access of Project Members for more information.
- Installed gRPC and the gRPC tools. See Get started with gRPC for details.
- Configured Endpoints.
If you are using a custom domain name (for example,
must verify the domain name
before you can deploy the gRPC configuration files.
Preparing Cloud SDK for deployment
You use the
gcloud command line tool to
deploy the configuration. See the
gcloud Reference for more information about the commands.
To prepare for the deployment:
- Install and initialize the GCP SDK.
- Update GCP SDK:
gcloud components update
- Make sure that GCP SDK is authorized to access your data and
gcloud auth login
A new browser tab opens and you are prompted to choose an account.
- Set the default project. Replace
[YOUR-PROJECT-ID]with your GCP project ID
gcloud config set project [YOUR-PROJECT-ID]
- If you will be deploying your API backend to either Kubernetes or Kubernetes
Engine, run the following command to acquire new user credentials to use for
Application Default Credentials. The user credentials are needed to authorize
gcloud auth application-default loginA new browser tab opens and you are prompted to choose an account.
Deploying the configuration files
- Make sure you are in the directory where
- Deploy the proto descriptor file and the configuration file using the
gcloud endpoints services deploy api_descriptor.pb api_config.yaml
As it is creating and configuring the service, Service Management outputs a great deal of information to the terminal. On successful completion, you will see a line like the following that displays the service configuration ID and the service name:
Service Configuration [2017-02-13r0] uploaded for service [bookstore.endpoints.example-project.cloud.goog]
In the above example,
2017-02-13r0is the service configuration ID and
bookstore.endpoints.example-project.cloud.googis the service name. The service configuration ID consists of a date stamp followed by a revision number. If you deploy the Endpoints configuration again on the same day, the revision number is incremented in the service configuration ID.
If your service's configuration is in multiple YAML files, you can pass them all
deploy command. For example, the Bookstore has its basic configuration
api_config.yaml, but you can enable HTTP transcoding for the service by
api_config_http.yaml, which has additional configuration for
gcloud endpoints services deploy api_descriptor.pb api_config.yaml api_config_http.yaml
Note that if there are conflicting values in your YAML files, the values in the last specified file override the others. You can find out more about how Cloud Endpoints handles merging multiple YAML files in Configuring a gRPC API Service.
If you get an error message, see Troubleshooting Endpoints Configuration Deployment for information on troubleshooting the error.
Whenever you change something in your service configuration
yaml file, be sure
to deploy it again so that Cloud Endpoints has the most recent version
of your API's service configuration. If the configuration change does not require
that you redeploy your API (for example, perhaps you changed
false), if you have previously deployed
ESP with the
rollout option set to
you do not need to redeploy/restart ESP. This option
configures ESP to use the latest deployed service configuration. When you
specify this option, within a minute after you deploy a new service
configuration, ESP detects the change and automatically begins using it. We
recommend that you specify this option instead of a specific configuration ID
for ESP to use.