Cloud Computing, DevOps, Google Cloud (GCP)

5 Mins Read

A Guide to Implement Dockerization and Deploy Monolithic Applications on Google Cloud Run

Voiced by Amazon Polly

Overview

In today’s fast-paced world of software development, deploying applications quickly and efficiently is crucial. Dockerization and serverless platforms like Google Cloud Run have emerged as powerful tools to streamline deployment. In this blog post, we will guide you through creating a Docker image, pushing it to Artifact Registry, deploying the image on Google Cloud Run, and updating the application with zero downtime using the command-line interface (CLI).

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

Introduction

Google Cloud Run is a serverless computing platform that allows developers to deploy and manage applications as scalable, stateless containers. Leveraging the power of Kubernetes and Native, it offers a flexible and seamless way to run applications in the cloud.

With Google Cloud Run, developers can focus on writing code without worrying about infrastructure, benefiting from automatic scaling based on incoming request traffic. This platform promotes efficient resource utilization and cost-effective solutions for modern application development and deployment.

Pre-requisites

  • GCP Account: You need an active Google Cloud Platform (GCP) account.
  • Access to the Resources: Ensure you have access to the necessary resources within your GCP account to create and manage services.
  • Cloud Shell: Access to Google Cloud Shell, a browser-based terminal for interacting with GCP resources and executing commands.

Step-by-Step Guide

Step 1 – Replicate the Source Repository

If you are deploying a pre-existing website, duplicating the source is all you must do. This allows you to concentrate on generating Docker images and launching them on Google Cloud Run.

Begin by opening a new Cloud Shell window and executing the subsequent instructions to clone the Git repository and switch to the designated directory:

step1

Next, execute this command to install the NodeJS dependencies, enabling you to test the application before deployment:

step1b

This process will take a few minutes to complete. You will receive a confirmation of success once it’s done.

To test your application, initiate the web server by executing the following command:

step1c

step1d

Create one artifact registry in GCP to store the images built during this phase.

GCP console >> Artifact-registry >> Repositories >> Create Repository
Enter the below details and click on Create.

step1e

Step 2 – Configure Authentication:

Before attempting to push or pull images, it’s essential to configure Docker to utilize the Google Cloud CLI for authentication when requesting Artifact Registry.

To configure authentication for Docker repositories in the “asia-south1” region, execute the following command within Cloud Shell:

This command will update your Docker configuration, allowing you to connect with Artifact Registry in your Google Cloud project and facilitate image push and pull operations.

step2

First, enable the Google Cloud Build, Artifact Registry, and Google Cloud Run APIs. Use the following command to enable them:

step2b

Once the APIs are successfully enabled, initiate the build process by executing the following command:

step2c

step2d

Step 3 – Deploy the Container to Google Cloud Run

After successfully containerizing your website and pushing the container to Artifact Registry, it’s now time to proceed with the deployment on Google Cloud Run.

Deployment on Google Cloud Run can be accomplished through two approaches:

  1. Managed Google Cloud Run: This involves utilizing the Platform as a Service model, where the entire container lifecycle is managed by the Google Cloud Run product itself. This is the approach you’ll be using for this particular lab.
  2. Google Cloud Run on GKE: This approach offers an additional layer of control, allowing you to utilize your own clusters and pods from Google Kubernetes Engine (GKE). If you wish to learn more about this approach, you can find additional information [here](link_to_more_information).

To initiate the deployment of the image to Google Cloud Run, execute the following command:

step3

step3b

Step 4 – Modify the changes in code and start building the new image

Go to the artifact-registry and check for the image with version 2.0.

step4

Step 5 – Update application with zero downtime:

Now, it’s essential to update the website seamlessly, ensuring no disruption for the users. Cloud Run adopts an approach where each deployment is treated as a new Revision, gradually transitioning it online and then redirecting traffic to it.

step5

step5b

Conclusion

With Google Cloud Run, businesses achieve flexible, on-demand application execution while minimizing operational overhead. Its compatibility with various frameworks and rapid scaling capabilities makes it a powerful tool for modern, efficient software deployment.

Drop a query if you have any questions regarding Google Cloud Run and we will get back to you quickly.

Making IT Networks Enterprise-ready – Cloud Management Services

  • Accelerated cloud migration
  • End-to-end view of the cloud environment
Get Started

About CloudThat

CloudThat is an official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, Amazon QuickSight Service Delivery Partner, AWS EKS Service Delivery 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.

To get started, go through our Consultancy page and Managed Services PackageCloudThat’s offerings.

FAQs

1. What is Google Cloud Run and how does it differ from traditional serverless platforms?

ANS: – Google Cloud Run is a serverless computing platform that allows developers to deploy and run applications in containers. Unlike traditional serverless platforms, Google Cloud Run enables developers to use their own containerized code, providing more flexibility and compatibility with existing tools and frameworks.

2. How does scaling work in Google Cloud Run?

ANS: – Google Cloud Run automatically scales your application based on incoming request traffic. It can handle multiple requests concurrently by dynamically adjusting the number of container instances, ensuring optimal performance and responsiveness. This scaling is efficient and can handle both high and low traffic periods seamlessly.

WRITTEN BY Anil Kumar Y A

Anil Kumar Y A works as a Research Associate at CloudThat. He knows GCP Cloud Services and resources and DevOps tools like Docker, K8s, Ansible, and Terraform, and he is also passionate about improving his skills and learning new tools and technologies.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!