This project sets up a CI-Cd pipeline using google cloud build, in which the pipeline is triggered by a commit to the Github repo. The cloud build service will pull the code from repo and create an image using dockerfile, this image is then used to deploy the website on google kubernetes engine
- A developer pushes the source code to GitHub, which lends itself as the Version Control System.
- GitHub triggers a post-commit hook to Cloud Build.
- Cloud Build creates the container image and pushes it to Container Registry.
- Cloud Build notifies Google Kubernetes Engine to roll out a new deployment.
- Google Kubernetes Engine pulls the image from Container Registry and runs it.
├── Readme.md
├── Docs.md
├── cloudbuild.yaml
├── k8
│ ├── deployment.yaml
│ └── service.yaml
└── node-app
├── Dockerfile
├── index.js
├── package-lock.json
├── package.json
- Docs.md contains notes related to SRE and DevOps implementation using google*
- cloudbuild.yaml contains steps to be performed by google cloud build</li
- k8 directory contains the kubernetes files: deployment.yaml and service.yaml*
- node-app contains index.js which stores the code for our basic project, and a Dockerfile used for creation of images from the code
- The package.json file contains all the dependecies used*
- Note the Project-id and Project-number
- These will be used in the rest of setup and identified as [Project-id] and [Project-number] and need to be replaced with your values
- Run the following command in your terminal, so that you can interact with it from cli*
gcloud config set project [project-id]
git clone https://github.com/zigbee-s/gcp-devops-sre.git
docker build -t gcr.io/[Project-id]/node-app:latest .
gcloud services enable containerregistry.googleapis.com [to enable Google’s Container Registry API]
gcloud services enable container.googleapis.com [to enable Google’s Kubernetes Engine API]
gcloud services enable cloudbuild.googleapis.com [to enable the Cloud Build API]
Run the following command in your terminal
gcloud container clusters create gke-node-app \
--zone=europe-west1-d \
--machine-type=n1-standard-2 \
--enable-autoscaling \
--min-nodes=1 \
--max-nodes=3
Run the following command in your terminal
gcloud projects add-iam-policy-binding [PROJECT-ID] \
--member='serviceAccount:[PROJECT_NUMBER]@cloudbuild.gserviceaccount.com' \
--role='roles/container.admin'
- Navigate to cloud build, select trigger and click on Connect repository*
- Select github as the source*
- Select the GitHub account, repository and click on Connect Repository:*
Run the following command in your terminal
gcloud beta builds triggers create github \
--name=[Github Repo name] \
--description="Push to branch" \
--repo-name=[Github Repo name] \
--repo-owner=[Github Owner name] \
--branch-pattern="^main$" \
--build-config=cloudbuild.yaml
You will see something like this:
Run the following command in your terminal
kubectl get svc





