Deploying a gRPC API

This page describes how to deploy an API configuration to Cloud Endpoints for a gRPC service, using our Bookstore sample service as an example. This procedure creates the runtime service configuration for your service and uploads it to Cloud Endpoints. Once you've done this, you can deploy your service backend to Container Engine or Compute Engine with the Extensible Service Proxy (ESP), ready to receive client requests. You can see how to deploy the entire Bookstore service to the environment of your choice in our Tutorials.

Configuring Endpoints

  1. Create a self-contained protobuf descriptor file from your service .proto file:
    1. Save a copy of bookstore.proto from our example repo. This file defines the Bookstore service's API.
    2. Create the descriptor file using the protocol buffers compiler, protoc:

      protoc --include_imports --include_source_info bookstore.proto --descriptor_set_out out.pb

      You may need to provide additional flags (-I) for the root directories for the imported .proto files.

  2. Create a gRPC API Configuration YAML file:
    1. Save a copy of api_config.yaml. This file defines the gRPC API configuration for the Bookstore service.
    2. Replace <MY_PROJECT_ID> in your api_config.yaml file with your Cloud Platform Console project ID.

      Note that the apis: name value in this file exactly matches the fully-qualified API name from the .proto file; otherwise deployment won't work. The Bookstore service is defined in bookstore.proto inside package endpoints.examples.bookstore. Its fully-qualified API name is endpoints.examples.bookstore.Bookstore, just as it appears in api_config.yaml.

        - name: endpoints.examples.bookstore.Bookstore

Deploying the Endpoints Configuration

  1. Deploy the proto descriptor file and the configuration file using the gcloud command-line tool:
    gcloud service-management deploy out.pb api_config.yaml
  2. Wait for this operation to complete. After it is done, take a note of the service name and the service config ID in the command output, you'll need this when deploying your backend:
    Service Configuration [SERVICE_CONFIG_ID] uploaded for service [SERVICE_NAME]

    When you copy the service name and service configuration ID, do not include the square brackets.

If your service's configuration is in multiple YAML files, you can pass them all to the deploy command. For example, the Bookstore has its basic configuration in api_config.yaml, but you can enable HTTP transcoding for the service by also deploying http_api_config.yaml, which has additional configuration for this feature:

gcloud service-management deploy out.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](/endpoints/docs/grpc/grpc-service-config).

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Cloud Endpoints with gRPC