Dev Ops
Dev Ops
1
Introduction
DevOps is a combination of development (Dev) and operations (Ops) practices, principles and tools designed to improve
collaboation between software developement teams and IT operations teams. The goal is to deliver high-quality software more
quickly and reliably while maintaining system stability
2
History & Motivation
Waterfall Methodology (1980- early 2000):
Software development followed the linear waterfall model, where requirement, development, testing and deployment
occured in separate phases
Operation teams managed infrastructure, while developers focused on coding, often leading to poor communication
and collaboration
Challenges: Slow delivery cycles, misaligned priorities, deployment failures, and a lack of agility in responding to
customers needs
Agile movement (2001):
The Agile manifesto introduced iterative development, focusing on collaboration, customer feedback, and small,
incremental releases
While Agile improved software development speed, it didn't address operational inefficiencies or the gap between
development and operations
3
History & Motivation
Foundations of DevOps (2007-2009)
2007: Patrick Debois, a Belgian IT consultant, coined the term Agile infrastructure te describe applying Agile principles
to infrastructure and operations
2008: At an Agile conference in Toronto, Debois discussed the disconnect between developers and system
administrators
4
History & Motivation
2009: Birth of DevOps
Debois organized the first DevOpsDays in Ghent, Belgium, where devekopers and IT operations professionals
gathered to discuss collaboration and automation
The term DevOps was officially coined during this event
5
Gowth and adoption (2010s)
Continuous Integration (CI) tools like Jenkins, Bamboo, and TeamCity gained popularity for automating code
integration and testing
Continuous Delivery (CD) concepts began to emerge, emphasizing automated deployments
The rise of cloud platforms like AWS (2006), Microsoft Azure (2010), and Google Cloud (2011) made it easier to
provision and scale infrastructure
2013: Docker revolutionized containerization, enabling developers to package applications and dependencies into
portable containers
Tools like Terraform (2014) and Ansible (2012) simplified the managment of infrastructure configuration using code
Kubernetes (2014), developed by Google, became the leading orchestration tool for managing containerized
applications
6
Modern Era of DevOps (2020s)
DevSecOps: Security became an integral part of DevOps workflows, leading to the rise of DevSecOps. This approach
embeds security practices into every stage of the development lifecycle.
GitOps: Git-based workflows for managing infrastructure and deployments gained traction, leveraging tools like Flux and
AgroCD
Platform Engineering: Organizations began building internal developer platforms to simplify DevOps processes and
improve developer productivity
Widespread adoption: Entreprises worldwide adopted DevOps practices to stay competitive, supported by certifications
(AWS DevOps, Kubernetes CKA)
7
Key components of the DevOps lifecycle
8
Plan
Purpose: Define project requirements, set goals, and outline workflows for the software development process.
Activities:
Example: A product team uses Jira to create epics and user stories for a new feature in an e-commerce platform. Tasks are
assigned to developers and tracked on a Kanban board.
9
Code
Example: Developers work on a feature branch in GitHub and submit pull requests for review.
Automated checks run on the code before it's merged into the main branch
10
Build
Purpose: Compile source code into executable artifacts and ensure build consistency across environments.
Activities:
Example: A CI pipeline in Jenkins is configured to trigger a Maven build whenever new code is pushed to the repository.
The build generates a .jar file for a Java application, which is stored in an artifact repository like JFrog Artifactory or Nexus.
11
Test
Purpose: Ensure the application works as intended and is free of critical defects.
Activities:
Example: A Jenkins pipeline packages a Python application as a Docker image and uploads it to a container registry like Docker
Hub or Amazon ECR.
13
Deploy
Example: Kubernetes orchestrates a rolling update of a containerized microservice in production, ensuring no downtime.
Terraform provisions new cloud infrastructure for the application during deployment.
14
Operate
Purpose: Manage, monitor, and ensure the reliability of the deployed application.
Activities:
Example: Prometheus collects application metrics (e.g., response time, error rate).
Grafana visualizes the metrics on dashboards for the operations team to monitor in real time.
15
Monitor
Purpose: Gather insights and feedback to continuously improve the application and user experience.
Activities:
Example: ELK Stack aggregates and analyzes logs from a microservices application, helping the team troubleshoot performance
issues.
PagerDuty sends alerts to the on-call engineer when the application experiences downtime. 16
Example DevOps Workflow
Scenario: A fintech company develops an online payment application.
Plan: Product managers create user stories in Jira for a new "Quick Pay" feature.
Code: Developers implement the feature, committing code to a GitHub repository.
Build: Jenkins triggers a Maven build to compile the Java code and create a .jar file.
Test: JUnit tests verify API functionality, while Selenium scripts validate the UI in different browsers.
Release: The tested .jar file is packaged into a Docker image.
Deploy: Kubernetes deploys the Docker container in a production cluster using a Blue-Green deployment strategy.
Operate: Prometheus monitors API response times and generates alerts for anomalies.
Monitor: Feedback from customers and monitoring dashboards informs further improvements to the "Quick Pay" feature.
By iterating through these phases, the company continuously delivers and improves its application, ensuring a high-
quality user experience.
17
18
Benefits of DevOps
DevOps bridges the gap between development and operations, enabling organizations to deliver high-quality software faster
and more efficiently.
1. Faster Time to Market: DevOps accelerates the software delivery lifecycle through automation, streamlined processes, and
enhanced collaboration. Continuous Integration (CI) and Continuous Deployment (CD) pipelines ensure that new features
and fixes are deployed quickly and frequently.
2. Improved Collaboration and Communication: DevOps fosters a culture of collaboration between development,
operations, and other teams. By breaking silos, teams share responsibility for the application's lifecycle, from planning to
monitoring.
3. Enhanced Efficiency through Automation: Automation of repetitive tasks such as code integration, testing, deployment,
and infrastructure provisioning reduces manual errors and speeds up processes.
19
Benefits of DevOps
4. Better Quality and Stability: Continuous testing and monitoring in DevOps workflows ensure that bugs are caught early,
leading to more stable and reliable applications. Automated testing helps maintain code quality across frequent releases
5. Reduced Risk and Faster Recovery: With practices like continuous monitoring, automated rollbacks, and deployment
strategies (e.g., Blue-Green or Canary), DevOps minimizes the risk of downtime and enables quick recovery from failures.
6. Scalability and Flexibility: DevOps practices make it easier to scale infrastructure and applications dynamically to meet
changing user demands. Tools like Terraform enable Infrastructure as Code (IaC), which simplifies scaling operations.
20
Benefits of DevOps
7. Continuous Feedback and Improvement: Monitoring tools provide real-time insights into application performance and
user behavior. This data informs future development and optimizations.
8. Cost Savings: Automation, efficient resource utilization, and faster problem resolution reduce operational costs.
Additionally, shared responsibility among teams reduces the need for specialized silos.
9. Better User Experience: Faster updates, reliable services, and rapid bug fixes improve customer satisfaction. Monitoring
tools help identify and resolve performance issues proactively.
10. Competitive Advantage: By delivering features faster, maintaining high reliability, and responding quickly to user needs,
companies gain a competitive edge in their markets.
21
DevOps Culture and Mindset
DevOps is more than a set of tools or processes; it's a cultural shift and mindset that emphasizes collaboration, communication,
and shared responsibility between development and operations teams. It aligns technology, processes, and people to achieve a
common goal: delivering high-quality software faster and more reliably.
Mindset Shift:
22
DevOps Culture and Mindset
From: "What's easiest for the team?"
To: "What's best for the customer?"
23
Version Control Systems (VCS)
24
Version Control Systems (VCS)
A Version Control System (VCS) is a tool that helps teams manage changes to source code and other files over time. It tracks
the history of modifications, enables collaboration among multiple developers, and helps ensure that code is well-organized
and secure. VCS is a critical component of the DevOps process and supports practices like Continuous Integration (CI) and
Continuous Deployment (CD).
25
Motivation
26
Key Features of Version Control Systems
1. Version History
Keeps a chronological record of changes to files and allows users to revert to previous versions.
Example: A developer uses git log to view all commits made to a project.
Enables developers to create branches to work on new features independently and later merge changes back into the
main branch.
Example: In Git, a new branch can be created with git branch feature-xyz , and it can be merged with git merge .
3. Collaboration
Multiple team members can work on the same project simultaneously. Conflict resolution mechanisms ensure
seamless integration of changes.
Example: A team of developers collaborates on GitHub, creating pull requests for code review before merging their
work.
27
Key Features of Version Control Systems
4. Conflict Management
Identifies and resolves conflicts when multiple developers edit the same file.
Example: Git highlights merge conflicts, allowing developers to decide how to combine conflicting changes.
6. Security
Tracks who made what changes and when, enhancing accountability. Some systems also offer access controls.
Example: GitHub allows administrators to restrict write access to certain branches.
28
Git
Git is a Distributed Version Control System (DVCS) designed to handle the tracking, management, and collaboration of
code changes in software projects. It allows multiple developers to work on a project simultaneously without overwriting
each other's changes, maintaining a complete history of modifications, and providing tools to branch, merge, and rollback
changes as needed.
Git is widely used in software development for its speed, scalability, and efficiency. It was created by Linus Torvalds in 2005
to manage the Linux kernel development.
29
Getting started
Installation:
1. https://git-scm.com/downloads
2. To check if Git is installed: git --version
Configuration:
30
How Git Works
1. Repository
A repository (repo) is the project folder that Git tracks. It contains all the files, changes, and the history of the project.
To create a new repo: git init
Creating new files and then git status
31
How Git Works
Commit the file (It is like taking a snapshot of you project at a certain point => Making a whole new copy of your folder
and telling Git to remember when you did it) Regular commits helps you keep track of your progress and makes it easier
to revert to previous versions if anything breaks git commit -m 'Add readme.md file'
32
How Git Works
To see the history: git log
33
How Git Works
Detached HEAD: it's a state where the HEAD pointer no longer points at the latest branch commit
34
How Git Works
To go back to the current state: git checkout main
35
Branching
Branching in Git is a way to create separate versions of your codebase for developing features, fixing bugs, or experimenting,
without affecting the main or production-ready code. A branch is essentially a lightweight movable pointer to a commit in the
Git repository.
They are simply pointers to a specific commit -- nothing more. This is why many Git enthusiasts chant the mantra:
36
Branching
To create a new branch: git branch bugFix
37
Branching
The branch bugFix now refers to commit C1.
git commit
38
Branching
Let's tell git we want to checkout the branch with: git checkout <name>
This will put us on the new branch before committing our changes.
git checkout bugFix
git commit
To create a new branch and switch to it at the same time use: git checkout -b branch-name
39
Branching
40
Branching
41
How Git Works
Command Description Example
git clone Creates a local copy of a remote repository. git clone <repo-url>
git status Shows the current state of the working directory and staging area. git status
git add Stages changes for the next commit. git add file.txt
git commit Records staged changes in the repository history. git commit -m "Commit message"
git pull Fetches and integrates changes from a remote repository. git pull origin main
git push Sends committed changes to a remote repository. git push origin main
git checkout Switches between branches or restores files. git checkout feature-xyz
git merge Combines changes from one branch into another. git merge feature-xyz
42
Git vs GitHub
Git is a tool for version control that allows developers to:
1. Repository hosting.
2. Collaboration among teams (e.g., pull requests and code reviews).
3. Managing project issues and enhancements.
4. Integrating with CI/CD pipelines for automated testing and deployment.
43
DevOps and CI/CD
44
DevOps and CI/CD
CI/CD is an essential element of integrated DevOps throughout the entire pipeline, from initial planning to continuous
feedback and
improvement
45
DevOps and CI/CD
46
Continuous integration (CI)
The practice of regularly merging a developer's code into the centralized code base and perform automated testing to
ensure that no regression has been introduced.
Aligns with the Code, Build and Test phases and Test phases of the DevOps pipeline
47
Continuous integration (CI)
What is it for?
Merge conflicts
Code errors
Incompatibilities
48
Continuous integration (CI)
What are the stages in continuous integration?
Planning development
49
Continuous Delivery (CD)
Practice aimed at automating the process of deployment of a verified software version to test or production environments,
whenever a new version is ready.
50
Continuous Delivery (CD)
The decision is often taken by a member of the development or deployment team, or by a quality manager.
51
Continuous Deployment (CD)
Every code change that passes automated testing is automatically deployed to the production environment, without
human intervention
Does not involve manual validation prior to deployment in the production environment
Requires high confidence in the effectiveness of automated testing and the stability of the production environment.
52
Continuous Delivery and Deployment (CD)
What is it for?
53
CI/CD with Gitlab
GitLab provides a built-in Continuous Integration/Continuous Deployment (CI/CD) system to automate the build, test, and
deployment of your software projects. Here's how to use GitLab CI/CD effectively.
Jobs:
Each stage contains jobs, which define specific tasks (e.g., compiling code, running tests).
.gitlab-ci.yml File:
The configuration file located in the root of your repository, defining the CI/CD pipeline.
Runners:
GitLab uses runners to execute CI/CD jobs. These can be shared (hosted by GitLab) or specific (hosted by you).
54
The .gitlab-ci.yml file is the heart of GitLab CI/CD. Here's a basic example:
stages:
- build
- test
- deploy
build-job:
stage: build
script:
- echo "Building the application..."
- mkdir build
- echo "Build complete."
test-job:
stage: test
script:
- echo "Running tests..."
- echo "All tests passed."
deploy-job:
stage: deploy
script:
- echo "Deploying the application..."
- echo "Deployment complete."
only:
- main
55
CI/CD with Gitlab
Stages:
Define the sequence of steps in the pipeline (e.g., build , test , deploy ).
Jobs:
Define tasks to be executed in each stage.
Run Pipelines
56
CI/CD with Gitlab
Variables allow you to configure pipelines dynamically: Add variables in Settings > CI/CD > Variables. Use them in
.gitlab-ci.yml :
deploy-job:
stage: deploy
script:
- echo "Deploying to $ENVIRONMENT"
variables:
ENVIRONMENT: production
cache:
paths:
- node_modules/
Artifacts: Store files generated during a job for use in later stages.
artifacts:
paths: 57
- build/
CI/CD with Gitlab
Deploy Automatically
Integrate your pipeline with deployment platforms. For example, deploy to AWS, Kubernetes, or any custom server.
deploy-job:
stage: deploy
script:
- aws s3 cp build/ s3://my-bucket --recursive
58
Benefits of GitLab CI/CD
Automation:
Reduces manual effort for testing, building, and deployment.
Fast Feedback:
Identifies code issues early in the development lifecycle.
Consistency:
Ensures uniform builds and deployments.
Integration:
Supports integrations with Kubernetes, Docker, AWS, and more.
59
Best Practices for GitLab CI/CD
GitLab CI/CD simplifies and accelerates the software delivery process, making it a powerful tool for modern development
workflows.
60
TP
Create a GitLab account
Automated tests
61
Containerization
62
Virtual Machiness VS Containers
63
Virtual Machine VS containers
Both containerization and traditional virtualization are technologies that allow running multiple isolated environments on a
single physical machine. However, they operate differently and are suited for different use cases.
64
Aspect Containerization Traditional Virtualization
Uses the host OS kernel and provides isolated user- Uses a hypervisor to run multiple guest OS
Architecture
space environments. instances on a host OS.
Lightweight, shares the host OS kernel; minimal Heavy, each VM includes a full guest OS,
Overhead
overhead. consuming more resources.
Startup Time Fast, containers can start in seconds or milliseconds. Slow, VMs may take minutes to boot up.
Highly portable; containers are consistent across Portable but requires compatibility between
Portability
environments. hypervisors.
65
Docker
Docker is an open-source platform that enables developers to build, ship, and run applications inside lightweight, portable
containers. These containers bundle an application and all its dependencies, ensuring consistency across different
environments, from development to production.
66