100% found this document useful (2 votes)
1K views178 pages

GCP DevOps Project

The document discusses setting up a continuous integration and continuous delivery (CI/CD) pipeline between a GitHub repository and a Kubernetes cluster on Google Cloud Platform (GCP). It describes that the pipeline would involve automatically building a Docker image, storing it in an artifactory, writing Kubernetes deployment and service YAML files, and configuring continuous delivery to deploy changes from GitHub to GKE using the Docker image.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
1K views178 pages

GCP DevOps Project

The document discusses setting up a continuous integration and continuous delivery (CI/CD) pipeline between a GitHub repository and a Kubernetes cluster on Google Cloud Platform (GCP). It describes that the pipeline would involve automatically building a Docker image, storing it in an artifactory, writing Kubernetes deployment and service YAML files, and configuring continuous delivery to deploy changes from GitHub to GKE using the Docker image.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

© Copyright KodeKloud

© Copyright KodeKloud
© Copyright KodeKloud
Creating a new GitHub repo

© Copyright KodeKloud
Setting up the repo according to
the company's best practices

© Copyright KodeKloud
Coding
Writing a code for a simple
docker image

© Copyright KodeKloud
Testing the code locally

© Copyright KodeKloud
Pushing the code to the
GitHub repo

© Copyright KodeKloud
GitHub Docker

© Copyright KodeKloud
Task 1
Creating a GitHub Repo

© Copyright KodeKloud
Creating a GitHub
Repository

© Copyright KodeKloud
Task 2
Cloning the repo and setting up our editor

© Copyright KodeKloud
© Copyright KodeKloud
© Copyright KodeKloud
Summary

Clone Setup Change Code

© Copyright KodeKloud
Task 3
Setting up GitHub repo according to
DevOps best practices

© Copyright KodeKloud
© Copyright KodeKloud
How to set up the GitHub repo?

© Copyright KodeKloud
GitHub Main Clone Make a
change

© Copyright KodeKloud
What is the Problem with this approach?

© Copyright KodeKloud
GitHub Main Clone Make a
change

© Copyright KodeKloud
Conflict

GitHub Main Clone Make a


change

© Copyright KodeKloud
How to improve?

© Copyright KodeKloud
Branch Protection

© Copyright KodeKloud
Pool Request

GitHub Main Clone Make a


change

© Copyright KodeKloud
Reviewed
Engineer Pool Request

GitHub Main Clone Feature


Branch
(task)

© Copyright KodeKloud
How to enable Branch Protection?

© Copyright KodeKloud
Task 4
Coding for our application locally

© Copyright KodeKloud
Develop code locally
and test it.

© Copyright KodeKloud
VS Code Editor

© Copyright KodeKloud
Demo
Testing, Debugging our code locally

© Copyright KodeKloud
Sprint-01
Review

© Copyright KodeKloud
Sprint Review in Organizations

Creating a new GitHub repo

Setting up the repo according to the company's best practices

Coding: Writing a code for a simple docker image

Testing the code locally

Pushing the code to the GitHub repo

© Copyright KodeKloud
© Copyright KodeKloud
Sprint-02

© Copyright KodeKloud
© Copyright KodeKloud
Creating a GCP account

© Copyright KodeKloud
Understanding the
fundamentals of GKE in GCP

© Copyright KodeKloud
Setting up a GKE cluster

© Copyright KodeKloud
Sprint Goals

Creating a GCP account

Understanding the fundamentals of GKE in GCP

Setting up a GKE cluster

© Copyright KodeKloud
Kubernetes Refresher

© Copyright KodeKloud
© Copyright KodeKloud
Definition of Kubernetes

Kubernetes, also known as K8s, is an open-


source system for automating the
,
and
of containerized applications.

© Copyright KodeKloud
How do we create it?

© Copyright KodeKloud
© Copyright KodeKloud
Deploy it

Scale it

Manage it

© Copyright KodeKloud
© Copyright KodeKloud
Kubernetes Features

Docker Image Version Production Pod

Pug
Automated Rollouts and Rollbacks

Achieving this
task is known
as

Version Production Pod

© Copyright KodeKloud
Kubernetes Features

Self - Healing

Service Discovery and Load Balancing

Security and Configuration Management

© Copyright KodeKloud
Where do we deploy the Kubernetes?

© Copyright KodeKloud
Cloud Options

AWS GCP Microsoft Azure

© Copyright KodeKloud
Own Datacentres

© Copyright KodeKloud
Pros & Cons

Organization

Cost

Big Team

© Copyright KodeKloud
How to setup the Kubernetes cluster in GCP?

© Copyright KodeKloud
Sprint-02 review

© Copyright KodeKloud
Sprint Review

Creating a GCP account

Understanding the fundamentals of GKE in GCP

Setting up a GKE cluster

© Copyright KodeKloud
© Copyright KodeKloud
Sprint-03

© Copyright KodeKloud
Design Discussion on CI/CD

CI CD

© Copyright KodeKloud
What is Design Discussion?

© Copyright KodeKloud
© Copyright KodeKloud
Google Cloud Platform

GKE

© Copyright KodeKloud
What is the next step?

© Copyright KodeKloud
© Copyright KodeKloud
How do we achieve this?

© Copyright KodeKloud
CI/CD

© Copyright KodeKloud
What are the steps required?

© Copyright KodeKloud
Design Discussion

CI CD

© Copyright KodeKloud
CI/CD Design Discussion

© Copyright KodeKloud
© Copyright KodeKloud
What are the steps required?

© Copyright KodeKloud
Automated way to build the docker
image.
GitHub GKE

© Copyright KodeKloud
We have to store the Docker image
in an artifactory.
GitHub GKE

© Copyright KodeKloud
Where do we store Docker image?

© Copyright KodeKloud
© Copyright KodeKloud
We have to write a deployment /
service YAML files for K8 deployment.
GitHub GKE

© Copyright KodeKloud
YAML

Horizontal Pot Ingress Deployment Service YAML


Autoscaling

© Copyright KodeKloud
We have to setup CD to deploy this
code to GKE using the docker image
GitHub stored in artifactory. GKE

© Copyright KodeKloud
Automated way to build the docker image.

We have to store the Docker image in an


artifactory.

We have to write a deployment/service


yaml files for K8 deployment.

We have to setup CD to deploy this code to


GitHub GKE using the docker image stored in GKE
artifactory.

© Copyright KodeKloud
How do you research?

© Copyright KodeKloud
YAML

GCP Documentation Deploy GitHub Repository YAML Files Answer

CI/CD Tool Research Open Source Read Code

© Copyright KodeKloud
Automated way to build the docker image.

We have to store the Docker image in an


artifactory.

We have to write a deployment/service


yaml files for K8 deployment.

We have to setup CD to deploy this code to


GitHub GKE using the docker image stored in GKE
artifactory.

© Copyright KodeKloud
What tools in GCP can
help us achieve this ?

© Copyright KodeKloud
Automated way to build the docker image.

We have to store the Docker image in an


artifactory.

We have to write a deployment/service


yaml files for K8 deployment.

We have to setup CD to deploy this code to


GitHub GKE using the docker image stored in GKE
artifactory.

© Copyright KodeKloud
© Copyright KodeKloud
Automated way to
build the docker image. CD tool in GCP
Use it to build docker Image

© Copyright KodeKloud
We have to store the
Docker image in an
Store Docker Image
artifactory.

© Copyright KodeKloud
We have to write a
deployment/service Use it to deploy our
yaml files for K8 image to GKE cluster.
deployment.

© Copyright KodeKloud
We have to setup CD to
deploy this code to
GKE using the docker Use it to deploy our
image stored in image to GKE cluster.
artifactory.

© Copyright KodeKloud
How does Cloud Build work?

© Copyright KodeKloud
How does GCP Artifactory work?

© Copyright KodeKloud
Services in GCP

Cloud Build

GCP Artifact Registry

© Copyright KodeKloud
GCP
Cloud
GitHub 1 1 Artifact GKE
Build
Registry

Cloud
2 2
Build

1 Build and store Docker Image 2 Deploy Docker Image to GKE

© Copyright KodeKloud
Sprint-03 review

© Copyright KodeKloud
Design Discussion on CI/CD

CI CD

© Copyright KodeKloud
What is Cloud Build in GCP?

© Copyright KodeKloud
What is GCP Artifact Registry?

© Copyright KodeKloud
What is GCP Artifact Registry?

© Copyright KodeKloud
GCP
Cloud
Artifact
Build
Registry

© Copyright KodeKloud
© Copyright KodeKloud
Sprint-04

© Copyright KodeKloud
Cloud Build

© Copyright KodeKloud
What are the features of Cloud Build?

© Copyright KodeKloud
?
Cloud Build GitHub Repository

© Copyright KodeKloud
Automate Docker Image GCP Artifact Registry
Build Process

© Copyright KodeKloud
Sprint Goals

Understanding Cloud Build in details

How to connect Cloud Build to GitHub Repository?

Automate Docker Image build process

© Copyright KodeKloud
Cloud Build in detail

© Copyright KodeKloud
© Copyright KodeKloud
What are the features of Cloud Build?

© Copyright KodeKloud
What are the driving factors?

© Copyright KodeKloud
CICD
CICD

CICD

CI CD

CICD

© Copyright KodeKloud
Build software quickly across all programming
languages, including Java, Go, [Link] and more.

© Copyright KodeKloud
Choose from 15 machine types and run hundreds
of concurrent builds per pool.

© Copyright KodeKloud
Deploy across multiple environments such as
VMs, serverless, Kubernetes, or Firebase.

© Copyright KodeKloud
CI CD

Access cloud-hosted, fully managed CI/CD


workflows within your private network.

© Copyright KodeKloud
Keep your data at rest within a geographical
region or specific location with data residency.

© Copyright KodeKloud
Takeaways

It is a complete serverless CI/CD platform

No Infrastructure to maintain

Pricing: E2 – Medium serverless $0.003 per build/minute

YAML
Code: Written in YAML file

© Copyright KodeKloud
YAML

© Copyright KodeKloud
?
GitHub Repository Cloud Build

© Copyright KodeKloud
When is Cloud Build triggered?

© Copyright KodeKloud
Cloud Build trigger

© Copyright KodeKloud
When is Cloud Build triggered?

© Copyright KodeKloud
Jenkins Webhooks GitHub

© Copyright KodeKloud
What events to be used to trigger?

© Copyright KodeKloud
How to trigger the Cloud Build?

© Copyright KodeKloud
GitHub Cloud Build Trigger Cloud Build

© Copyright KodeKloud
What is the trigger?

© Copyright KodeKloud
© Copyright KodeKloud
© Copyright KodeKloud
Any push on the
main/master branch will
trigger our Cloud Build

© Copyright KodeKloud
[Link] file shall contain
the CD code

© Copyright KodeKloud
Quick walkthrough

© Copyright KodeKloud
Recap

Make code changes


GitHub

Commit the changes to GitHub

Open a pull request (PR)


Cloud
Merge the PR to the main/master repo Build

Cloud Build is triggered

GCP
Cloud Build will store the Docker image Artifact
to the Artifact Registry Registry

© Copyright KodeKloud
Sprint-04 review

© Copyright KodeKloud
Sprint Goals

Understand Cloud Build in detail

Learn to connect Cloud Build to GitHub repo

Automate Docker image build process

© Copyright KodeKloud
© Copyright KodeKloud
Sprint-05

© Copyright KodeKloud
Extending the CI/CD process to deploy our Docker image on a GKE cluster

CI/CD Docker Image GKE

© Copyright KodeKloud
When will it be completed?

© Copyright KodeKloud
© Copyright KodeKloud
Why is it so?

© Copyright KodeKloud
CI/CD Docker Image GKE

© Copyright KodeKloud
© Copyright KodeKloud
How to break the task?

© Copyright KodeKloud
© Copyright KodeKloud
© Copyright KodeKloud
Creating a namespace in our GKE cluster

© Copyright KodeKloud
Creating a deployment file

© Copyright KodeKloud
Updating the Cloud Build code for deployment

© Copyright KodeKloud
Validating the deployment

© Copyright KodeKloud
Creating a namespace in our GKE cluster

Creating a deployment file

Updating the Cloud Build code for deployment

Validating the deployment

© Copyright KodeKloud
Sprint-05 review

© Copyright KodeKloud
Extending the CI/CD process to deploy our Docker image on a GKE cluster

CI/CD Docker Image GKE

© Copyright KodeKloud
Sprint Goals

Creating a namespace in our GKE cluster

Creating a deployment file

Updating the Cloud Build code for deployment

Validating the deployment

© Copyright KodeKloud
© Copyright KodeKloud
Sprint-06

© Copyright KodeKloud
YAML

Extending our [Link] file to also include


code to expose our application via an endpoint

© Copyright KodeKloud
What is this service called?

© Copyright KodeKloud
How to expose our application?

© Copyright KodeKloud
Sprint-06 review

© Copyright KodeKloud
YAML

Extending our [Link] file to also include code to expose our application via an endpoint

© Copyright KodeKloud
© Copyright KodeKloud
Sprint-07

© Copyright KodeKloud
© Copyright KodeKloud
!

© Copyright KodeKloud
© Copyright KodeKloud
We are requested to setup a
development environment

© Copyright KodeKloud
How do we do that?

© Copyright KodeKloud
What is a development environment?

© Copyright KodeKloud
Application Development Development Main Branch
Environment

© Copyright KodeKloud
How do we set it up?

© Copyright KodeKloud
Upgrade replicas
using the new flow

© Copyright KodeKloud
© Copyright KodeKloud
Deployment process using the Development Environment

© Copyright KodeKloud
Deployment process using the Development Environment

Application Production Production


Environment

© Copyright KodeKloud
Sprint-07 review

© Copyright KodeKloud
Dev Ops

Develop Test Deploy

Deploy the changes to production


using the right DevOps lifecycle

© Copyright KodeKloud
© Copyright KodeKloud

You might also like