Cloud Run
Connecting to GCP Cloud Run from a DevZero workspace.
If you're more of a visual learner, check out the video tutorial!
Architecture Diagram
GCP Cloud Run is a serverless service offered by GCP to manage a computing platform that enables you to run invocable containers via requests or events. In this, we will set up a pipeline for our project within DevBox; it will be routed through Cloud Run. Then, depending on the type of project, we can either access it through the web or through the internal VPC of Google Cloud Infrastructure.
Existing Cloud Run Application
If you have an existing Cloud Run Container deployed, follow the steps below to access its content from the DevBox. Ensure the Cloud Run Deployment has the Require authentication
option selected in the Security section.
Step 1: Creating a Recipe
First, we need to create a recipe for the workspace:
- Go to the DevZero Dashboard > Recipes and click on New recipe.
- Enter the recipe name and click on Create a recipe.
- Now use the below-provided snippet to create a recipe for your workspace:
- Click on Save and Build and when the build is successful, move on to the next step.
Step 2: Creating a Workspace
- Go to the Devzero Dashboard > Workspaces by clicking New workspace.
- Enter the workspace name and click on Select from recipe library.
- Select the recipe you just created above and click on Select.
- Click on Launch, and your workspace will be ready shortly.
Step 3: Setting up cloud SDK
Now, this is where the real task begins. After downloading the gcloud
package, we must authenticate with our Google Cloud account. To do this, we need to run the simple command.
After running the command, you will be given various options for choosing your Google account, default Project, and default Compute Region and Zone. You can choose what you prefer.
Step 4: Accessing the Container
To access your Cloud Run container privately, you need to send a GET
request with an authentication token.
Follow the below steps to generate the Authentication token and access the Cloud Run application:
- Use the below command to get the token:
- Export the token to an environmental variable:
- Now that everything is set, we can finally finish this all off by accessing the applications with the
curl
command:
New Cloud Run Application
If you want to create a new Cloud Run Container, you can follow the below steps.
Step 1: Creating the Container
- Go to Cloud Run > Services and click Deploy Container.
- Choose a deployment method between Deploy one revision from an existing container image, Continuously deploy from a repository (source or function).
We are creating a container with an existing demo image for this guide.
- Enter your Container Image URL or select by clicking on Select.
- Then Enter your Service Name and Region of deployment.
- Select Require authentication option in the Authentication section.
- Leave the remaining configurations as default and click on Create.
Step 2: Creating a Recipe
First, we need to create a recipe for the workspace:
- Go to the DevZero Dashboard > Recipes and click on New recipe.
- Enter the recipe name and click on Create a recipe.
- Now use the below-provided snippet to create a recipe for your workspace:
- Click on Save and Build and when the build is successful, move on to the next step.
Step 3: Creating a Workspace
- Go to the Devzero Dashboard > Workspaces by clicking New workspace.
- Enter the workspace name and click on Select from recipe library.
- Select the recipe you just created above and click on Select.
- Click on Launch, and your workspace will be ready shortly.
Step 4: Setting up cloud SDK
Now, this is where the real task begins. After downloading the gcloud
package, we must authenticate with our Google Cloud account. To do this, we need to run the simple command.
After running the command, you will be given various options for choosing your Google account, default Project, and default Compute Region and Zone. You can choose what you prefer.
Step 5: Accessing the Container
To access your Cloud Run container privately, you must send a GET
request with an authentication token.
Follow the below steps to generate the Authentication token and access the Cloud Run application:
- Use the below command to get the token:
- Export the token to an environmental variable:
- Now that everything is set, we can finally finish this all off by accessing the applications with the
curl
command: