Voiced by Amazon Polly
Cloud Run is a fully managed compute platform that enables you to run stateless containers that are invocable via HTTP requests. It abstracts away infrastructure management and scaling, allowing developers to focus on building and deploying applications quickly. In this blog, we will cover the process of deploying an application on Cloud Run, from creating a container image to exposing it to the public internet.
By the end of this blog, you will have a basic understanding of how to deploy a containerized application on Cloud Run and some of the features it offers to make it easy to run your applications in the cloud.
Google Cloud Run is a fully managed serverless platform for running stateless containers. It allows developers to build and deploy their applications as Docker containers, without having to manage the underlying infrastructure. Cloud Run automatically handles scaling, load balancing, and maintenance, enabling developers to focus on building and deploying their applications, rather than managing infrastructure.
Applications deployed on Cloud Run are highly scalable and can automatically handle increased traffic, making it an ideal platform for deploying microservices and serverless applications. Additionally, Cloud Run supports a wide range of programming languages, making it a flexible and versatile platform for building and deploying cloud-native applications.
Helping organizations transform their IT infrastructure with top-notch Cloud Computing services
- Cloud Migration
- AIML & IoT
Benefits of Cloud Run
There are several benefits to using Google Cloud Run:
- Serverless computing: Cloud Run allows developers to build and deploy their applications as containers, without having to manage the underlying infrastructure.
- High scalability: Cloud Run automatically handles scaling and load balancing, ensuring that applications can handle increased traffic and perform reliably, even during periods of high demand.
- Easy to use: Cloud Run provides a simple, user-friendly interface for deploying and managing containers, making it accessible to developers of all skill levels.
- Low latency: Cloud Run is designed to provide low latency, ensuring that applications respond quickly to user requests.
- Cost-effective: Cloud Run is priced on a pay-per-use basis, meaning that users only pay for the resources they consume, making it a cost-effective solution for running containers in the cloud.
- Secure: Cloud Run is built on the same infrastructure that powers other Google services, ensuring that applications are secure and protected from threats.
- Flexible: Cloud Run supports a wide range of programming languages and frameworks, making it a flexible platform for building and deploying cloud-native applications.
Overall, Cloud Run provides an easy-to-use, scalable, and cost-effective solution for running containers in the cloud, enabling developers to focus on building and deploying their applications, rather than managing infrastructure.
- A Google Cloud project and have required permission on it.
- gcloud CLI must be set up on the local environment.
- Make sure you have logged in using gcloud CLI. Otherwise use “gcloud auth login” to log in.
- Make sure you’ve chosen the right project
Steps to Deploy Cloud Run service using a pre-built container:
Step 1 – Using Cloud Console:
- Open the Cloud Run page and click on Create Service.
Step 2 – On the next screen, put the URL of the container image, the name of the Cloud Run service, and then select the region you want to deploy your Cloud Run service.
- You can also specify the autoscaling setting for the Cloud Run service. You also need to select the authentication type. Select “Allow unauthenticated invocations” if you want your service to be accessible to public users.
- Then click “Create”. After the deployment has finished, you’ll get a URL to access your Cloud Run service.
Using gcloud CLI:
Step 1 – You can use the “gcloud run deploy” command to deploy the Cloud Run service.
- This will create a Cloud Run service with the specified image using all the default options. You can know more about other options/flags on the official page.
Deploying your source code from the local environment
If your application is written in Go, Node.js, Python, Java, .NET Core, or Ruby, the source-based deployment option is available to you, allowing the creation of containers using optimal practices specific to the language.
- For this blog, I’m using a sample NodeJS application that prints “This is working.” on the website. To deploy it, we need to run the “gcloud run deploy” command with the “—source” flag. This command will first trigger Cloud Build to make a container out of the source code and push it to the container/artifact registry. Then, it will pull that container and deploy that on Cloud Run.
- After running the command, we can see that a Cloud Build operation has started to build the container and push it to Container Registry.
- After the deployment is finished, you’ll get the Cloud Run service’s URL on the terminal.
Setup continuous deployment on Cloud Run using GitHub
Continuous deployment with GitHub and Cloud Run involves automatically deploying code changes from a GitHub repository to Google Cloud Run. The process integrates automated testing and deployment processes to ensure code changes are thoroughly tested and deployed efficiently. This streamlines the development process, reduces errors and downtime, and enables organizations to release new features and improvements faster and with greater confidence, improving the user experience.
- While creating the Cloud Run service, choose the following and set up the Cloud Build.
- While setting up the Cloud Build, choose the provider and select the repository. If you can’t find your repo, this might be due to GCP doesn’t have access to it. Click on “Manage connected repositories” to give GCP access to your repo.
- In the next screen, you’ll be prompted to select the branch, build type, and command to start the server. If you have a Dockerfile, Cloud Build will build the container using it. I’ve selected the programming language.
- Then click “Save”. Now your source repository and Cloud Build trigger are set up. Then, you can select other Cloud Run options (Autoscaling, authentication, etc.) as per your use case and deploy the service. While deploying, it will pull the codes from the repo, build a container from it, and deploy that on Cloud Run. You can view all these steps in the Cloud Build operation.
- To test if it is working, push some changes in the specified branch and check the Cloud Build page. After some time, you’ll get a Cloud Build Operation running, which will update the Cloud Run service and deploy the new source code.
Deploying an application on Cloud Run is a simple and efficient way to manage and scale your application. With the benefits of serverless computing and automatic scaling, Cloud Run makes it easy to run your containerized applications on Google Cloud. Additionally, its pay-per-use pricing model means you only pay for the resources you use, which can help you save costs in the long run. Whether you’re a small start-up or a large enterprise, Cloud Run is a great choice for deploying and managing your applications in the cloud.
Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.
- Cloud Training
- Customized Training
- Experiential Learning
CloudThat is also the official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft gold partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.
Drop a query if you have any questions regarding GCP Cloud Run and I will get back to you quickly.
1. What type of applications is Cloud Run suitable for?
ANS: – Cloud Run is suitable for microservices, serverless applications, and event-driven applications.
2. Does Cloud Run support custom domains?
ANS: – Yes, Cloud Run supports custom domains through the use of custom domain mapping. You can find more about it here.
3. Does Cloud Run have any limits or quotas?
ANS: – Yes, there are limits and quotas in place to ensure that Cloud Run operates efficiently and fairly for all users. You can find more about it here.
4. Can I scale my Cloud Run application automatically?
ANS: – Yes, Cloud Run can automatically scale your application up and down in response to incoming traffic. You can find more about it here.
5. Can I access logs and metrics for my Cloud Run applications?
ANS: – Yes, Cloud Run provides integrated logging and monitoring through Cloud Logging. You can find more about it here.
6. Can I run stateful applications on Cloud Run?
ANS: – No, Cloud Run is designed for stateless applications, as the containers are ephemeral and may be moved between instances at any time.
WRITTEN BY Avinash Kumar
Avinash Kumar is a Senior Research Associate at CloudThat, specializing in Cloud Engineering, NodeJS development, and Google Cloud Platform. With his skills, he creates innovative solutions that meet the complex needs of today's digital landscape. He's dedicated to staying at the forefront of emerging cloud technologies.