KEMBAR78
Dev Ops | PDF | Version Control | Virtual Machine
0% found this document useful (0 votes)
40 views66 pages

Dev Ops

DevOps is a methodology that integrates development and operations to enhance collaboration and deliver high-quality software rapidly. It evolved from traditional waterfall methodologies to agile practices, ultimately leading to the establishment of DevOps in 2009, which emphasizes automation, continuous integration, and continuous delivery. Key components of the DevOps lifecycle include planning, coding, building, testing, releasing, deploying, operating, and monitoring, all aimed at improving efficiency and user experience.

Uploaded by

Amz
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
0% found this document useful (0 votes)
40 views66 pages

Dev Ops

DevOps is a methodology that integrates development and operations to enhance collaboration and deliver high-quality software rapidly. It evolved from traditional waterfall methodologies to agile practices, ultimately leading to the establishment of DevOps in 2009, which emphasizes automation, continuous integration, and continuous delivery. Key components of the DevOps lifecycle include planning, coding, building, testing, releasing, deploying, operating, and monitoring, all aimed at improving efficiency and user experience.

Uploaded by

Amz
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
You are on page 1/ 66

DevOps

Pr. Amal Ourdou


Email: a.ourdou@usms.ma

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)

Rise of Infrastructure Automation:


Tools like Puppet (2005) and Chef (2009) emerged, enabling teams to automate infrastructure provisioning and
configuration
These tools laid the groundwork for treating infrastructure as code (IaC)

Agile Infrastructure and DevOps

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)

Emergence of CI/CD and automation tools:

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

Cloud computing and containerization:

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

Infrastructure as Code (IaC):

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:

Collaborate with stakeholders to gather requirements.


Use Agile methodologies like Scrum or Kanban for iterative planning.
Create user stories, tasks, and backlogs.
Tools: Jira, Trello, Azure DevOps, Monday.com

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

Purpose: Write, review, and manage code collaboratively.


Activities:

Developers write and test code locally.


Use version control systems to track changes.
Perform peer code reviews to ensure quality.
Tools: Git, GitHub, GitLab, Bitbucket, Visual Studio 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:

Automate the process of building the software.


Resolve dependencies using build tools.
Ensure reproducible builds with consistent configurations.
Tools: Maven, Gradle, Ant

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:

Execute unit, integration, and performance tests.


Automate testing for faster feedback.
Use test coverage tools to measure the extent of testing.
Tools: Selenium, JUnit, TestNG, Postman, Cypress

Example: Automated Selenium scripts validate the UI functionality of a web application.


JUnit tests ensure the correctness of backend APIs.
Postman tests verify REST API endpoints in the application 12
Release

Purpose: Package the tested application for deployment.


Activities:

Prepare release notes and documentation.


Use versioning systems to manage releases.
Automate deployment processes to minimize downtime.
Tools: Jenkins, CircleCI, Azure DevOps, Bamboo

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

Purpose: Deliver the application to production or staging environments.


Activities:

Automate deployments to reduce errors.


Implement deployment strategies like Blue-Green, Canary, or Rolling.
Roll back deployments if issues arise.
Tools: Kubernetes, Docker, Terraform, AWS Elastic Beanstalk

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:

Monitor performance and availability.


Perform routine maintenance.
Automate scaling and failover processes.
Tools: Prometheus, Grafana, AWS CloudWatch, Splunk

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:

Monitor logs, metrics, and user behavior.


Set up alerts for critical incidents.
Analyze feedback for future enhancements.
Tools: ELK Stack (Elasticsearch, Logstash, Kibana), Datadog, New Relic, PagerDuty

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:

From: "It's not my job."


To: "We're all responsible for delivery."

From: Developers focus on features; operations focus on stability.


To: Everyone is accountable for delivering stable and functional software.

From: Avoid risks and mistakes.


To: Fail fast, learn faster.

From: Manual processes are good enough.


To: Automate everything that can be automated.

22
DevOps Culture and Mindset
From: "What's easiest for the team?"
To: "What's best for the customer?"

From: Decisions based on opinions or assumptions.


To: Decisions driven by data and evidence.

From: "Focus on individual tasks."


To: "Optimize the end-to-end flow of work."

From: "Don't speak up; it's risky."


To: "Your input matters, and we'll fix problems together."

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).

Centralized Version Control Systems (CVCS)


A central server stores all versions of files, and developers sync their local copies with the server.
Examples: SVN (Subversion), Perforce, CVS (Concurrent Versions System).
Benefits: Easier collaboration, a single source of truth.
Limitations: Dependency on a central server; if the server is down, work stops.

Distributed Version Control Systems (DVCS)


Each developer has a complete copy of the repository, including its full history.
Examples: Git, Mercurial, Bazaar.
Benefits: Faster operations (since they are performed locally), better support for offline work, and improved resilience (no single
point of failure).

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.

2. Branching and Merging

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.

5. Backup and Recovery

Maintains a backup of code, reducing the risk of losing critical work.


Example: A developer accidentally deletes a file but restores it from version history.

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:

1. Associate Git with your name To know who to blame ;)


git config --global user.name "<Your-Full-Name>"

2. Associate Git with email


git config --global user.email "<your-email-address>"

3. Rename the main branch name:


git config --global init.defaultBranch main
main is the default branch name of the repo created by Git (everytime you initialize git, this branch would be automatically
created)

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

To track the files: git add readme.md

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'

Rerunning git status

To track all the files: git add .

32
How Git Works
To see the history: git log

To restore an old version: git checkout commit_hash

33
How Git Works

git checkout commit_hash

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

git checkout -f 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:

branch early, and branch often

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 init Initializes a new Git repository in a directory. git init

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 branch Lists, creates, or deletes branches. git branch feature-xyz

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

git log Shows the commit history. git log

42
Git vs GitHub
Git is a tool for version control that allows developers to:

1. Track changes to code files.


2. Create branches for experimentation or feature development.
3. Merge changes and resolve conflicts.
4. Work offline and sync changes with others when connected.

GitHub is a platform built around Git that simplifies:

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

Automates the development, testing and deployment deployment

The aim is to:

Optimize development time,


Improve productivity,
Increase efficiency
Ensure rapid, reliable and continuous delivery of high-quality software

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?

Quickly detect and resolve

Merge conflicts
Code errors
Incompatibilities

Guarantee consistent software quality and smooth integration integration of functionalities.

Strengthen collaboration within development teams. teams.

48
Continuous integration (CI)
What are the stages in continuous integration?

Planning development

Compile and integrate code

Test the code

Evaluate code quality

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.

Requires human intervention to trigger the deployment process to production. production.

50
Continuous Delivery (CD)
The decision is often taken by a member of the development or deployment team, or by a quality manager.

This decision may be based on various factors, such as :

Stability of the version to be deployed


Resource availability: deployment can be scheduled for a time when the impact on end-users is minimal, for example,
outside peak hours.
Coordination with other teams or stakeholders
Corporate policies: regarding production deployments, such as regular maintenance windows.

51
Continuous Deployment (CD)

Continuous deployment is an extension of continuous delivery

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?

Guarantee that every successful code change is potentially deployable to production

Speed up the development cycle

Improve software quality

Foster a culture of collaboration and continuous improvement within teams.

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.

GitLab CI/CD Pipelines:


A pipeline consists of one or more stages (e.g., build, test, deploy).

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 in the same stage run in parallel.

Jobs:
Define tasks to be executed in each stage.

Run Pipelines

Push changes to the repository.


GitLab automatically detects the .gitlab-ci.yml file and triggers the pipeline.
Monitor pipeline progress in the CI/CD > Pipelines section of your project.

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: Speeds up pipelines by reusing dependencies.

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.

Example for AWS:

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

Use meaningful stage and job names.

Use caching to speed up pipelines.

Secure sensitive data using GitLab’s CI/CD Variables.

Keep pipelines short and efficient.

Monitor pipeline performance regularly.

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

CI/CD pipeline for an angular application:

Automated tests

Automated deployment in Gitlab pages

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.

Slightly lower performance due to full OS


Performance Near-native performance due to lower overhead.
emulation.

Startup Time Fast, containers can start in seconds or milliseconds. Slow, VMs may take minutes to boot up.

Isolation Process-level isolation. Stronger isolation with full OS separation.

Resource Less efficient; each VM requires dedicated OS


Efficient; containers share the host OS kernel.
Utilization resources.

Highly portable; containers are consistent across Portable but requires compatibility between
Portability
environments. hypervisors.

Legacy applications, running different OS types,


Use Cases Microservices, CI/CD, application packaging.
strong isolation.

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

You might also like