Automatically building and deploying containers into Cloud Run when changes pushed to CSR repository.

Image for post

GCP Serverless CI/CD Pipeline Architecture

Overview

In this article, we’ll see how to configure a CI/CD pipeline on GCP using Cloud Source Repository, Cloud Build, Container Registry and Cloud Run.

Cloud Source Repository

Google Cloud Source Repositories are fully featured, private Git repositories hosted on Google Cloud Platform. Collaborate easily and securely manage your code on a fully featured, scalable, private Git repository.

Cloud Build

Cloud Build is a service that executes your builds on Google Cloud Platform infrastructure. Cloud Build can import source code from Google Cloud Storage, Cloud Source Repositories, GitHub, or Bitbucket, execute a build to your specifications, and produce artifacts such as Docker containers or Java archives.

Container Registry

Container Registry is a private container image registry that runs on Google Cloud.

Cloud Run

Fully managed compute platform for deploying and scaling containerized applications quickly and securely


Setup the GCP Project

To follow this tutorial, you will need access to GCP Project

  1. Access the GCP console, enter a name for your new project and click the CREATE button
  2. Select APIs & Service and then click on the ENABLE APIS AND SERVICES
  3. Enable these APIs: Cloud Source Repositories API, Cloud Build APIGoogle Container Registry API and the Cloud Run API.

The Sample Application

The sample application we’ll use for this tutorial is a very simple Flask application.

If you want to know more about the app, please follow my previous blog

This is config service using Google Sheet.

It exposes two endpoints

  • /project/<>/env/<>/key/<>: a endpoint to get value of the key.
  • /spreadsheet/<>/worksheet/<>/id/<>: returns data belongs to the id.

vikramshinde12/config-service-googlesheet

This repository creates Docker image which can be deployed on Docker, Kubernetes (GKE) and Google Cloud Run. Create a…

github.com

Dockerfile

The Dockerfile of sample application


Create Service Account

Go to cloud shell (right corner “>_” ) icon. Run following command

gcloud iam service-accounts create sample-app

The service account created as ‘sample-app@$PROJECT_ID.iam.gserviceaccount.com’

Create Repository in Cloud Source Repository

This step will create repository in Cloud Source Repository and then clone it from Github.

  1. From left menu select, Cloud Source Repository. Then select Add repository.

Image for post

Create Repository

2. Enter the repository name and project name.

#google-cloud-platform #ci-cd-pipeline #google-cloud-run #serverless #devops

CI/CD Pipeline on GCP
10.85 GEEK