This deck was presented at Lendingkart meetup in Bangalore covering our experiences with creating CI/CD Pipeline with Kubernetes. Here is the video link of the meetup.
https://youtu.be/YraPL_NGmcs
3. Why CI/CD: Initial Lendingkart Platform !
● Started with 2 Backend, 2 UI Developers, 1 QA
● As new developers joined the team, it was difficult to understand and
maintain the monolithic
● Initial monolithic catered to customer & ops with minimal features.
● Stability was a major worry as we had to deploy features and bugs on a
daily basis
● Vertical scaling of our database server on a regular basis
4. Why CI/CD: Monolith
● Lending involves 3 major pieces: Origination, Credit analysis, Loan
management
● Our initial monolithic involved Customer, Origination and Credit analysis
modules (Spring MVC) structured on the lines of SOA
● For Loan management we used a third party service to avoid re-inventing
the wheel
5. Why CI/CD: Monolith to Microservice Architecture
● First microservice was in the form of lead service , followed by notification
service
● Subsequent break of our monolithic to microservice happened in the form
of customer, credit analysis, audit, reports, scheduler, webhooks, etc
● The greatest advantage was that since our requirements were changing
fast, we could make the changes quickly on the microservice and make it
more mature over time
7. Why CI/CD: How We Moved to Microservices Architecture
Monolithic to Microservice architecture
UI
MySQL DB
Business logic
Data Access Layer
MySQL DB MongoDB MySQL
Microservice
Customer
Microservice
Ops
Microservice
Notification
Microservice
Credit Analysis
Nginx
UI UI UI UI
8. How We Broke Our Monolithic !
● Lead
● Audit
● Customer
● Schedulers
● Webhooks
● Search
● Authentication & Authorization
● Crypto
● Notifications
(Many more)
9. Problems in Existing Release & Deployment Cycle
● Too many releases every week. (Thanks to microservices!)
● Too many failures and rollbacks required manually.
● Failed machines, applications, deployments go unnoticed and would need manual intervention to
bring up.
● Too many machines to be managed and procured for the release by devops.
● Every new project/service need new infrastructure & automation.
● QA needs to understand different release process for different projects like spring mvc, spring
boot, node js, UI etc.,
● No standard way of releasing all the projects.
● Growing infrastructure cost due to individual machine/servers for each service/replicas.
12. Gitlab CI
Gitlab repository .gitlabci.yml RunnerGitlab CI
Gitlab CI is a
powerful tool
for
continuously
test and
deploy the
code.
It contains all the
configuration of
what CI will do
with your
repository.
Runner can be a
VM, docker
container or
cluster of
machines which
runs the jobs
that are defined
in gitlabci.yml.
Gitlab Container
Registry
Every project can have its own space to store its
Docker images. Build and push the images to
registry.
14. Docker
A container is a standard unit of software
that packages up code and all its
dependencies so the application runs
quickly and reliably from one computing
environment to another.
ROI & Cost Saving
Immutable
Rapid Deployment
Standardization
16. KOPS (kubernetes operations)
Kops is basically a Kubernetes project used to manage Kubernetes cluster to AWS.
To create K8s cluster you should have:-
- S3 Bucket
- IAM Permissions
- DNS
Important Commands:-
kops create cluster --name <cluster_name> --zones <zone> --state <s3_bucket> --yes
kops get clusters --state="s3://k8s-lkart-clusters"
kops validate cluster --state="s3://k8s-lkart-clusters"
kops edit ig nodes --state="s3://k8s-lkart-clusters"
kops delete cluster --name <cluster_name> --state="s3://k8s-lkart-clusters" --yes
17. Kops Advantages
● Deploy clusters to existing virtual private clouds (VPC) or create a new VPC from scratch
● Supports public & private network topologies
● Provisions single or multiple master clusters
● Configurable bastion machines for SSH access to individual cluster nodes
● Rolling cluster updates
● Supports heterogeneous clusters by creating multiple instance groups
18. Kubernetes to Rescue!
In broad term, “Kubernetes is orchestration layer which decouples your application deployments from
underlying infrastructure” !
19. Kubernetes: Features/Advantages
● Orchestration layer
● Decouple Infrastructure from Applications.
● Cluster management
● Service discovery
● Make better use of your hardware resources
● Scale containerized applications and their resources on the fly.
● Declaratively manage services, which guarantees the deployed applications are always running
how you deployed them
● Health-check and self-heal your apps with auto placement, autorestart, auto replication, and
autoscaling.
● Horizontal scaling.
● Rolling updates (zero downtime).
20. Kubernetes: Architecture replication controller,
endpoints controller,
namespace controller,
and service accounts
controller
Individual node
monitoring
Node agent to communicate
with masters & manage pod
metrics Network proxy for the
pods to communicate
Storage stack
for secrets,
definitions, state
of system
24. Phase 1: Dockerize & Deploy
● Deployed containers on existing machines without any changes in network topology.
● Logs mounted to local disks.
Challenges:
● Memory leaks
● Incorrect containers dockerized.
● No profiling
● No resource limits
25. Phase 2: Critical Applications Migration to K8s
● Started dockerizing all services.
● Deployed & Stabilized the applications.
● Stabilization of cluster.
Challenges:
● Logs, disk full, temp data
● Stateful applications.
● Encryption till the container.
● Monitoring & Alerts
Primary: Rishabh
Advantages
Building blocks: ci, registry, runner.
CI: pipelines, jobs, stages, environment variables.
Add sample gitlabci.yml
What is gitlab CI?
Primary: Rishabh
Advantages
Building blocks: dockerfile, container, base image etc.,
Sample docker files for various projects.
Advantages of using docker:-
ROI and Cost Saving: Fewer resources are necessary to run the application which in turn provide better resource utilisation
Standardization: Standardizing service infrastructure across the entire pipeline allows every team member to work on a production parity environment.
Rapid Deployment:
Remove security
Add both screen shot for Spring MVC and Spring boot
Primary: RIshabh
Advantages
Building blocks: dockerfile, container, base image etc.,
Sample docker files for various projects.
Advantages of kops refer confluence page
Master nodes are used to manage k8s cluster.
Primary: Mihir
Primary: Mihir
Primary: Mihir
Primary: Mihir
Primary: Mihir
Primary: Mihir
A network file system (NFS) is a type of file system mechanism that enables the storage and retrieval of data from multiple disks and directories across a shared network.
A network file system enables local users to access remote data and files in the same way they are accessed locally.