Connecting to GCP Cloud Run Service from your DevBox.
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.
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.
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, click on Publish.
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.
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.
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:
If you want to create a new Cloud Run Container, you can follow the below steps.
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.
Click on Set Up with Cloud Build and follow the instructions.
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.
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, click on Publish.
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.
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.
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: