Invoke application deployed in Cloud Run from Apigee Proxy

Google Cloud Tech
2 Mar 202306:21

Summary

TLDRThis tutorial demonstrates deploying a Cloud Run application and an Apigee proxy using Cloud Build. It covers setting up the environment, enabling necessary APIs, and assigning roles for Cloud Build service account. The process includes building a container image, pushing it to Container Registry, and deploying it to Cloud Run. An Apigee service account with invoker role is created for accessing Cloud Run. The tutorial concludes with testing the API call to ensure successful deployment and a reminder to clean up resources.

Takeaways

  • 🔧 Demonstrates how to call a Cloud Run app from Apigee using Cloud Build for deployment.
  • ☁️ Cloud Run is a managed platform for deploying containers on Google's scalable infrastructure.
  • 🛠️ Cloud Build is a managed CI/CD platform for automated builds.
  • 🔑 Prerequisites include Apigee exposure, external access configuration, and GCP deployment permissions.
  • 🛠️ Required tools are gcloud, unzip, curl, and jq.
  • 📝 The tutorial can be followed using Cloud Shell with QuickStart.
  • 💻 Sets up environment variables in an 'environment.sh' file for the deployment process.
  • 🔄 Enables necessary APIs like IAM, Cloud Build, Cloud Run, and Container Registry.
  • 👤 Assigns roles to the Cloud Build service account for Apigee and Cloud Run access.
  • 🚀 Triggers Cloud Build to deploy the application and sets up the service account for Apigee access.
  • 🔗 Modifies the target URL in the 'cloudbuild.yaml' file to point to the Cloud Run service.
  • 📈 Tests the API call to ensure successful deployment and returns the expected service message.
  • 🗑️ Reminds viewers to clean up resources after deployment.

Q & A

  • What is Cloud Run and how does it relate to the video's content?

    -Cloud Run is a managed compute platform that allows users to run stateless containers that are invocable via HTTP requests. It is part of Google Cloud's scalable infrastructure. In the video, Cloud Run is used to deploy a sample application that is then accessed via an API deployed through Apigee.

  • What is the role of Cloud Build in the context of this video?

    -Cloud Build is Google Cloud's fully managed continuous integration and delivery platform. In the video, it is used to automate the deployment of a Cloud Run application by building a container image, pushing it to Container Registry, and then deploying it to Cloud Run.

  • What is Apigee and how does it interact with Cloud Run in the video?

    -Apigee is an API management platform that allows developers to create, manage, and secure APIs. In the video, Apigee is used to deploy a proxy that acts as an intermediary for the Cloud Run service, enabling API traffic management and access control.

  • What are the prerequisites for the sample demonstrated in the video?

    -The prerequisites include having an Apigee environment configured for external access, the ability to deploy a proxy to Apigee, deploy an application to Cloud Run, and the ability to trigger a Cloud Build job in the GCP project.

  • What tools does a user need to have installed to follow the video tutorial?

    -A user needs to have tools like gcloud, unzip, curl, and jq installed to follow the tutorial. These tools are necessary for interacting with Google Cloud services and managing the deployment process.

  • How does the video demonstrate the setup of the environment for deploying the Cloud Run application?

    -The video demonstrates environment setup by using Cloud Shell with QuickStart, authenticating with GCP, navigating to the Cloud Run directory, and setting up environment variables in an 'environment.sh' file.

  • What APIs need to be enabled before deploying the Cloud Run samples?

    -Before deploying the Cloud Run samples, the IAM API, Cloud Build API, Cloud Run API, and Container Registry API need to be enabled.

  • What roles and permissions are assigned to the Cloud Build service account in the video?

    -The Cloud Build service account is assigned the Apigee Org Admin role, Cloud Run Admin, and Service Account Admin and User roles to facilitate the deployment process.

  • What is the content of the application deployed to Cloud Run as per the video?

    -The application deployed to Cloud Run is a simple Node.js application that prints the text 'Mocktarget Service.' This is demonstrated in the 'app.js' file within the 'app' directory.

  • How is the Apigee proxy deployed in the video?

    -The Apigee proxy is deployed using a 'cloudbuild.yaml' file that outlines steps for building the container image, pushing it to the container registry, and deploying it to Cloud Run. It also sets up a service account with the invoker role and changes the target URL to the Cloud Run endpoint before running the Maven deploy bundle step.

  • How can one test the successful deployment of the Cloud Run application and Apigee proxy?

    -After deployment, one can test the API call to ensure that the deployment was successful. In the video, this is demonstrated by making an API call that returns the expected response 'Mocktarget Service.'

Outlines

00:00

🚀 Deploying Cloud Run and Apigee Integration

The speaker introduces a tutorial on deploying a Cloud Run application and setting up a proxy in Apigee. Cloud Run is described as a managed platform for container deployment on Google's scalable infrastructure, while Cloud Build is a CI/CD platform for automated builds. The tutorial requires prerequisites such as Apigee exposure, external access configuration, and user permissions for deploying proxies and applications. Essential tools like gcloud, unzip, curl, and jq are necessary. The demonstration uses Cloud Shell with QuickStart, guiding through environment setup, authentication, directory navigation, and environment variable configuration. The video also covers enabling necessary APIs and assigning roles to the Cloud Build service account. The application to be deployed is a simple Node.js app, and the deployment process is detailed in the cloudbuild.yaml file, which includes building a container image, pushing it to the registry, and deploying it to Cloud Run. Lastly, it sets up a service account with the invoker role for Apigee to access Cloud Run.

05:03

🔧 Testing and Cleanup After Deployment

This paragraph details the final steps of the deployment process, including triggering the Cloud Build, which may take some time to complete. Upon completion, the service 'mock-target' is deployed in Cloud Run, and a proxy 'sample-cloud-run' is deployed in Apigee. The speaker demonstrates testing the API call to ensure successful deployment, which returns the expected 'Mocktarget Service.' message. The video concludes with a reminder to clean up the resources used and thanks the viewers for watching. It also provides a sign-up link for Apigee and directs viewers to the Apigee community for any questions.

Mindmap

Keywords

💡Cloud Run

Cloud Run is a managed platform offered by Google Cloud that allows users to deploy containerized applications. It is designed to automatically scale the application based on the incoming traffic, providing a scalable infrastructure without the need for manual intervention. In the video, Cloud Run is used to deploy a sample application, showcasing its ease of use and scalability. The script mentions setting up a Cloud Run application and deploying it using Cloud Build.

💡Apigee

Apigee is an API management platform that allows organizations to publish, monitor, and secure APIs. It provides tools for developers to create, test, and manage APIs, ensuring they are scalable and secure. In the context of the video, Apigee is used to deploy a sample proxy, which is a key component in managing and routing API traffic. The script discusses using Apigee's build and deploy plugin to deploy the proxy.

💡Cloud Build

Google Cloud Build is a fully managed continuous integration and delivery service that automates the steps required to build, test, and deploy applications. It supports various programming languages and frameworks, and integrates with other Google Cloud services. In the video, Cloud Build is used to deploy a Cloud Run application, demonstrating its role in automating the deployment process. The script outlines the steps to trigger a Cloud Build job.

💡IAM API

The IAM API, or Identity and Access Management API, is a service within Google Cloud that allows for the management of access control to resources. It enables the creation and management of roles and permissions for users and services. In the video, the IAM API is mentioned as one of the APIs that need to be enabled before deploying the Cloud Run application, highlighting its importance in managing access to Google Cloud resources.

💡Service Account

A service account in Google Cloud is a special type of account used by applications and services to access Google Cloud resources. It is secured with a private key and is often used for automation and server-to-server interactions. In the video, the script mentions creating a service account with the invoker role to access Cloud Run, illustrating the use of service accounts for secure access to cloud resources.

💡Container Registry

Google Container Registry is a private registry for storing Docker containers. It is part of Google Cloud's services and is used to store, manage, and serve container images. In the video, the script refers to pushing a container image to the Container Registry, which is a step in the deployment process for a Cloud Run application.

💡Cloud Shell

Google Cloud Shell is a browser-based command-line tool that provides access to a virtual machine with the Google Cloud SDK pre-installed. It allows users to run commands and scripts directly in the browser to manage Google Cloud resources. The video script mentions using Cloud Shell with QuickStart to demonstrate the deployment process, showcasing its utility for cloud operations.

💡Environment Variables

Environment variables are dynamic values that can affect the way running processes will behave on a computer. They are often used in application development to configure settings without changing the application's code. In the video, environment variables are set in the 'environment.sh' file to configure the deployment process for the Cloud Run application.

💡API Traffic

API traffic refers to the data requests and responses that are sent and received through APIs. Managing API traffic is crucial for ensuring the performance and security of applications that rely on APIs. The video script mentions configuring external access for API traffic, which is a step in setting up the environment for deploying the Cloud Run application and Apigee proxy.

💡Maven

Apache Maven is a build automation tool used primarily for Java projects. It is used to manage project builds, dependencies, and documentation. In the video, Maven is mentioned as a tool used to deploy the Apigee proxy, indicating its role in automating the deployment process for API management.

💡Clean Up

In cloud computing, 'clean up' refers to the process of removing or deleting resources that are no longer needed to avoid incurring unnecessary costs. The video script ends with a reminder to clean up, which is a best practice in cloud resource management to ensure that only necessary resources are maintained.

Highlights

Demonstration of calling a Cloud Run app from Apigee.

Use of Cloud Build for deploying a Cloud Run application.

Utilization of Apigee build and deploy plugin for sample proxy deployment.

Introduction to Cloud Run as a managed platform for container deployment.

Explanation of Cloud Build as a CI/CD platform for automated builds.

Prerequisites for the sample include Apigee exposure and external access configuration.

Requirements for user access to deploy proxies to Apigee and applications to Cloud Run.

Necessity of tools like gcloud, unzip, curl, and jq for the sample.

Demonstration using Cloud Shell with QuickStart tutorial.

Instructions on setting up environment and authenticating with GCP.

Guidance on setting environment variables in the environment.sh file.

Enabling of IAM API, Cloud Build API, Cloud Run API, and Container Registry API.

Assignment of roles to the Cloud Build service account for API access.

Triggering of Cloud Build to initiate deployment processes.

Overview of the application in the app directory and its functionality.

Explanation of the cloudbuild.yaml file and its steps for building and deploying.

Creation of a service account with invoker role for Apigee to access Cloud Run.

Modification of the target URL to the Cloud Run endpoint for Apigee proxy deployment.

Execution of deploy bundle step to deploy the Apigee proxy.

Observation of Cloud Build completion and deployment of services in Cloud Run and Apigee.

Testing the API call to confirm successful deployment.

Advice on cleaning up resources after deployment.

Invitation to sign up for Apigee and engage with the Apigee community for questions.

Transcripts

play00:01

SPEAKER: Hi.

play00:02

In this sample, I will demonstrate

play00:04

how to call a Cloud Run app from Apigee.

play00:07

I will use Cloud Build to deploy a Cloud Run application

play00:11

and use the Apigee build and deploy plugin

play00:14

to deploy a sample proxy.

play00:17

Cloud Run is a managed contract platform

play00:20

that lets you wrap containers directly

play00:23

on top of Google's scalable infrastructure.

play00:26

And Cloud Build is a fully managed continuous integration

play00:30

delivery and deployment platform that

play00:32

lets you run fast, consistent, and reliable automated build.

play00:38

The prerequisite for the samples are--

play00:40

have an Apigee exposure and configure external access

play00:44

for API traffic.

play00:46

As a user, you will need access to deploy a proxy to Apigee,

play00:51

deploying an application to Cloud Run,

play00:53

and also trigger a Cloud Build job in the GCP project.

play00:58

Have tools like gcloud, unzip, curl, and jq installed.

play01:03

The sample can be demonstrated using the Cloud Shell

play01:06

Quickstart tutorial or following this setup instruction.

play01:11

In this video, we will use a Cloud Shell with QuickStart.

play01:17

Click the Open In Cloud Shell to open the Cloud Shell

play01:22

environment.

play01:26

Once the environment is loaded, let's follow the instructions

play01:37

provided in the tutorial.

play01:42

First, we will set up environment.

play01:46

We will authenticate with GCP.

play01:52

Then we will go to Cloud Run directory.

play02:02

We need to set up environment variables.

play02:05

For that, we need to edit environment dot sh file and add

play02:13

some variables.

play02:16

So in this case, our project is--

play02:24

we will set other variables.

play02:33

Once all the variables are set, we will Save this file,

play02:39

and we will run the source command

play02:45

to initiate these variables in my shell.

play02:55

Before we deploy the Cloud Run samples,

play02:58

we need to enable IAM API, Cloud Build API, Cloud Run API,

play03:04

and Container Registry API.

play03:15

Once these APIs are enabled, we need

play03:18

to assign Apigee Org Admin role, Cloud Run Admin, and Service

play03:23

Account Admin and User role to the Cloud Build service

play03:27

account.

play03:39

Now we need to trigger Cloud Build.

play03:44

But before we trigger the Cloud Build,

play03:47

let's look at the application that we need

play03:49

to deploy in the Cloud Run.

play03:52

So application is available in the app directory,

play03:57

and you can look at the app.js file, which is a simple Node.js

play04:02

application which prints a text, "Mocktarget Service."

play04:11

Then let's look at the cloudbuild.yaml file.

play04:16

The first step is to build container image.

play04:20

Then it pushes the container image to container registry.

play04:25

Then it deploys that image to Cloud Run.

play04:30

Once it is deployed, Apigee needs a service account

play04:35

with invoker role to access Cloud Run.

play04:40

So this step sets those variables

play04:44

and creates the service account.

play04:50

Before it runs the Maven to deploy Apigee proxy,

play04:56

it needs to change the target url to that

play05:02

of the cloudrunandpoint url.

play05:06

And once all these variables are set,

play05:09

you run deploy bundle step to deploy the Apigee proxy.

play05:17

Now let's go and trigger the Cloud Build.

play05:25

This process takes some time.

play05:32

The Cloud Build is finished.

play05:37

You can see that the service called mock-target is deployed

play05:42

in Cloud Run and a proxy called sample-cloud-run

play05:46

is deployed in Apigee.

play05:52

You can test the API call to make sure the deployment was

play05:55

successful.

play06:03

As you can see, it returns "Mocktarget Service."

play06:07

Don't forget to clean up this.

play06:10

Thanks for watching.

play06:11

I hope this content was useful to you.

play06:13

If you have not signed up for Apigee yet, use this link.

play06:17

And if you have any questions, please

play06:19

visit the Apigee community.

Rate This

5.0 / 5 (0 votes)

Связанные теги
Cloud RunApigeeCloud BuildDeploymentGCPContainerInfrastructureCI/CDAutomationDevOps
Вам нужно краткое изложение на английском?