{"id":14,"date":"2026-08-29T17:59:37","date_gmt":"2026-08-29T17:59:37","guid":{"rendered":"http:\/\/192.168.15.145\/?p=14"},"modified":"2026-08-29T18:07:40","modified_gmt":"2026-08-29T18:07:40","slug":"how-to-write-10000-words-a-week","status":"publish","type":"post","link":"https:\/\/cloudsolvd.com\/?p=14","title":{"rendered":"Deploying Microservices on Google Cloud Platform with Jenkins, Terraform, and Cloud Run"},"content":{"rendered":"\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/cloudsolvd.com\/2024\/11\/06\/cicd-with-jenkins-terraform-and-cloud-run\/\"><img decoding=\"async\" src=\"https:\/\/cloudsolvd.com\/wp-content\/uploads\/2024\/11\/0_9Rk0-S4o8yANUOIT.png\" alt=\"\" style=\"aspect-ratio:1.5892514395393473;width:828px;height:auto\"\/><\/a><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\">This article provides a comprehensive guide to creating a CI\/CD pipeline that deploys microservices on Google Cloud Platform (GCP) using Jenkins, Terraform, and Cloud Run. Leveraging Jenkins for continuous integration, Terraform for Infrastructure as Code (IaC), and Cloud Run for containerized service hosting, we\u2019ll explore a robust solution to automate deployments to the production environment efficiently and reliably.<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Table of Contents<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Continuous Integration Tool \u2014 Jenkins<\/strong><\/li>\n\n\n\n<li><strong>IaC with Terraform<\/strong><\/li>\n\n\n\n<li><strong>Container Services on Google Cloud Platform<\/strong><\/li>\n\n\n\n<li><strong>Cloud Run<\/strong><\/li>\n\n\n\n<li><strong>Infrastructure Setup<\/strong><\/li>\n\n\n\n<li><strong>Code<\/strong><\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">1. Continuous Integration Tool \u2014 Jenkins<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Jenkins is a popular, open-source CI\/CD tool used for automating software development workflows, from testing to deployment. This article focuses on using Jenkins to deploy the latest Docker images to Cloud Run whenever a new code commit is pushed to GitHub.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Setup<\/strong>: Jenkins can run on any system with Java installed and can be set up using Docker, native system packages, or standalone.<\/li>\n\n\n\n<li><strong>Deployment<\/strong>: We\u2019ll configure Jenkins to automate image deployment to Cloud Run by monitoring code changes in GitHub.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. Infrastructure as Code \u2014 Terraform<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Terraform is an IaC tool that allows for managing cloud resources in a safe, repeatable way. Here, Terraform will handle the state of the Cloud Run service, updating it with the latest Docker image.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Container Services on Google Cloud Platform<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">GCP offers several containerized service options, including Google Kubernetes Engine (GKE), Cloud Run, and App Engine. In this article, we\u2019ll focus on Cloud Run for its ease of use and managed environment for container deployment.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. Cloud Run<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Cloud Run is a managed GCP service for deploying containerized applications without requiring server infrastructure management. It supports source-based deployment of containers, allowing for applications in various languages, including Go, Node.js, Python, and Java.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Key Features<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Dedicated HTTPS endpoints for services.<\/li>\n\n\n\n<li>Request-based auto-scaling.<\/li>\n\n\n\n<li>Integrated traffic management.<\/li>\n\n\n\n<li>Public and private service options.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">5. Infrastructure Setup<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In this setup:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Jenkins, Docker, Git, and Terraform<\/strong>&nbsp;are installed on a Compute Engine virtual machine.<\/li>\n\n\n\n<li><strong>GitHub repository<\/strong>&nbsp;acts as the source for code, with automatic Jenkins jobs triggered by commits.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Pipeline Workflow<\/strong>:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Developer commits code to GitHub.<\/li>\n\n\n\n<li>Jenkins job triggers, building a new Docker image and pushing it to Google Container Registry (GCR).<\/li>\n\n\n\n<li>Terraform updates the Cloud Run service with the new Docker image.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Configuration Steps<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Install Jenkins<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code># Install Jenkins on Ubuntu<br>curl -fsSL https:\/\/pkg.jenkins.io\/debian-stable\/jenkins.io.key | sudo tee \\<br>\/usr\/share\/keyrings\/jenkins-keyring.asc &gt; \/dev\/null<br>echo deb &#91;signed-by=\/usr\/share\/keyrings\/jenkins-keyring.asc] \\<br>https:\/\/pkg.jenkins.io\/debian-stable binary\/ | sudo tee \\<br>\/etc\/apt\/sources.list.d\/jenkins.list &gt; \/dev\/null<br>sudo apt-get update<br>sudo apt install openjdk-11-jdk -y<br>sudo apt-get install jenkins -y<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Configure Firewall Rules<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Allow Jenkins on port 8080 and set up a firewall rule for VM access.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Jenkins Setup<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Log in to Jenkins using the VM\u2019s IP and port 8080.<\/li>\n\n\n\n<li>Install the&nbsp;<strong>GitHub<\/strong>&nbsp;and&nbsp;<strong>Extended Email<\/strong>&nbsp;plugins.<\/li>\n\n\n\n<li>Configure webhooks in GitHub to trigger Jenkins jobs on code commits.<\/li>\n\n\n\n<li>Set up email notifications using SMTP for deployment status updates.<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">Service Account Setup<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Create a GCP service account with editor permissions for managing Cloud Run and GCR, and attach it to the VM instance.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Install Terraform<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code># Install Terraform on Ubuntu<br>sudo apt-get update &amp;&amp; sudo apt-get install -y gnupg software-properties-common curl<br>curl -fsSL https:\/\/apt.releases.hashicorp.com\/gpg | sudo apt-key add -<br>sudo apt-add-repository \"deb &#91;arch=amd64] https:\/\/apt.releases.hashicorp.com $(lsb_release -cs) main\"<br>sudo apt-get update<br>sudo apt-get install terraform<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">6. Code<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Jenkins Pipeline Script<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">In Jenkins, create a pipeline script (<code>Jenkinsfile<\/code>) with stages for building, testing, and deploying the Docker container to Cloud Run.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Example Pipeline Stages<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Git Clone<\/strong>: Downloads the latest code.<\/li>\n\n\n\n<li><strong>Docker Build &amp; Push<\/strong>: Builds a new Docker image and pushes it to GCR.<\/li>\n\n\n\n<li><strong>Email Notification<\/strong>: Sends deployment updates.<\/li>\n\n\n\n<li><strong>QA Approval<\/strong>: Manual approval step for quality checks.<\/li>\n\n\n\n<li><strong>Cloud Run Update<\/strong>: Updates the Cloud Run service with the latest image.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Summary<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This article demonstrates setting up a CI\/CD pipeline with Jenkins, Terraform, and Cloud Run on GCP. Jenkins monitors code commits in GitHub, triggering Terraform to deploy updates to Cloud Run automatically. This CI\/CD setup helps streamline deployments, reduce manual intervention, and speed up the release cycle.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ref:&nbsp;<a href=\"https:\/\/gitlab.com\/leonardompdutra\/rga_cloud_assessment\">https:\/\/gitlab.com\/leonardompdutra\/rga_cloud_assessment<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article provides a comprehensive guide to creating a CI\/CD pipeline that deploys microservices on Google Cloud Platform (GCP) using Jenkins, Terraform, and Cloud Run. Leveraging Jenkins for continuous integration, Terraform for Infrastructure as Code (IaC), and Cloud Run for containerized service hosting, we\u2019ll explore a robust solution to automate deployments to the production environment&#8230;<\/p>\n","protected":false},"author":1,"featured_media":10,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-14","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/cloudsolvd.com\/index.php?rest_route=\/wp\/v2\/posts\/14","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudsolvd.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudsolvd.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudsolvd.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudsolvd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14"}],"version-history":[{"count":3,"href":"https:\/\/cloudsolvd.com\/index.php?rest_route=\/wp\/v2\/posts\/14\/revisions"}],"predecessor-version":[{"id":37,"href":"https:\/\/cloudsolvd.com\/index.php?rest_route=\/wp\/v2\/posts\/14\/revisions\/37"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudsolvd.com\/index.php?rest_route=\/wp\/v2\/media\/10"}],"wp:attachment":[{"href":"https:\/\/cloudsolvd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudsolvd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudsolvd.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}