Skip to content

Latest commit

 

History

History

grpc

README.md

gRPC on Apigee

This sample shows how to use Apigee in front of your gRPC backends. For this example we will be using Cloud Run to host a gRPC server and configure it as a target server in Apigee. Apigee will act as a simple reverse proxy in front of the gRPC backend. For more detailed information on using gRPC proxies in Apigee, please refer to the official documentation.

Prerequisites

  1. Provision Apigee X

  2. Configure external access for API traffic to your Apigee X instance

  3. Access to deploy proxies, create products, apps and developers in Apigee

  4. Make sure the following tools are available in your terminal's $PATH (Cloud Shell has these preconfigured)

  5. The following GCP APIs will be enabled:

    • Cloud Run API
    • Container Registry API
    • Compute Engine API
  6. Make sure that you have ONE the following permissions:

    • Owner role
    • Editor role

    The following set of roles:

(QuickStart) Setup using CloudShell

Use the following GCP CloudShell tutorial, and follow the instructions.

Open in Cloud Shell

Setup instructions

  1. Clone the apigee-samples repo, and switch the grpc directory
git clone https://github.com/GoogleCloudPlatform/apigee-samples.git
cd apigee-samples/grpc
  1. Edit the env.sh file and configure the following variables:
  • PROJECT the project where your Apigee organization is located
  • NETWORK the VPC network where the PSC NEG will be deployed
  • SUBNET the VPC subnet where the PSC NEG will be deployed

Now source the env.sh file

source ./env.sh

Let's run the script that will create and deploy the resources necessary to test the gRPC functionality. This script will create the following:

  • An External Loadbalancer with an HTTP2 backend
  • Deploy a sample gRPC Greeter service to Cloud Run
  • Deploy an API proxy, target server, developer, app and api product

Finally it tests that the deployment and configuration has been successful.

  1. Run the deploy.sh script:
./deploy.sh

Manually Testing the gRPC Proxy

To manually test the proxy, make requests using grpcurl or another gRPC client:

grpcurl -H "x-apikey:$CLIENT_ID" -import-path $PWD/grpc-backend/examples/protos -proto helloworld.proto -d '{"name\":"Guest"}' <YOUR_APIGEE_GRPC_HOSTNAME>:443 helloworld.Greeter/SayHello"

Cleanup

If you want to clean up the artifacts from this example in your Apigee Organization, first source your env.sh script, and then run

./clean-up.sh