SPEAKER: Hi.
In this sample, I will demonstrate
how to call a Cloud Run app from Apigee.
I will use Cloud Build to deploy a Cloud Run application
and use the Apigee build and deploy plugin
to deploy a sample proxy.
Cloud Run is a managed contract platform
that lets you wrap containers directly
on top of Google's scalable infrastructure.
And Cloud Build is a fully managed continuous integration
delivery and deployment platform that
lets you run fast, consistent, and reliable automated build.
The prerequisite for the samples are--
have an Apigee exposure and configure external access
for API traffic.
As a user, you will need access to deploy a proxy to Apigee,
deploying an application to Cloud Run,
and also trigger a Cloud Build job in the GCP project.
Have tools like gcloud, unzip, curl, and jq installed.
The sample can be demonstrated using the Cloud Shell
Quickstart tutorial or following this setup instruction.
In this video, we will use a Cloud Shell with QuickStart.
Click the Open In Cloud Shell to open the Cloud Shell
environment.
Once the environment is loaded, let's follow the instructions
provided in the tutorial.
First, we will set up environment.
We will authenticate with GCP.
Then we will go to Cloud Run directory.
We need to set up environment variables.
For that, we need to edit environment dot sh file and add
some variables.
So in this case, our project is--
we will set other variables.
Once all the variables are set, we will Save this file,
and we will run the source command
to initiate these variables in my shell.
Before we deploy the Cloud Run samples,
we need to enable IAM API, Cloud Build API, Cloud Run API,
and Container Registry API.
Once these APIs are enabled, we need
to assign Apigee Org Admin role, Cloud Run Admin, and Service
Account Admin and User role to the Cloud Build service
account.
Now we need to trigger Cloud Build.
But before we trigger the Cloud Build,
let's look at the application that we need
to deploy in the Cloud Run.
So application is available in the app directory,
and you can look at the app.js file, which is a simple Node.js
application which prints a text, "Mocktarget Service."
Then let's look at the cloudbuild.yaml file.
The first step is to build container image.
Then it pushes the container image to container registry.
Then it deploys that image to Cloud Run.
Once it is deployed, Apigee needs a service account
with invoker role to access Cloud Run.
So this step sets those variables
and creates the service account.
Before it runs the Maven to deploy Apigee proxy,
it needs to change the target url to that
of the cloudrunandpoint url.
And once all these variables are set,
you run deploy bundle step to deploy the Apigee proxy.
Now let's go and trigger the Cloud Build.
This process takes some time.
The Cloud Build is finished.
You can see that the service called mock-target is deployed
in Cloud Run and a proxy called sample-cloud-run
is deployed in Apigee.
You can test the API call to make sure the deployment was
successful.
As you can see, it returns "Mocktarget Service."
Don't forget to clean up this.
Thanks for watching.
I hope this content was useful to you.
If you have not signed up for Apigee yet, use this link.
And if you have any questions, please
visit the Apigee community.