Devops(1)
Devops(1)
Topics
• Introduction - devops
• Tools in devops
• Git
• Maven
• Docker
3
Introduction to DevOps
Devops is the new SDLC method to reduce the gap between Development team
and Operations team, encouraging the improved collaboration between the both
teams, so that everyone can be involved with the code at any point in the
lifecycle.
4
Design-Code-Test-Deploy- Waterfall
Design-Code-Test-Code-Test-Code-Test-Deploy -Agile
Design-Code-Test-Deploy-Design-Code-Test-Deploy-Design-Code-Test-
Deploy -DevOps
5
Principles of Agile:
•Customer Satisfaction: satisfy the customer through early and
continuous delivery of valuable software.
•Welcome Change: Agile welcomes changing requirements, even late in
development,
to provide a competitive advantage.
•Frequent Delivery: Deliver working software frequently, with a
preference for shorter timescales.
•Collaboration: Business people and developers must work together
daily throughout the project.
•Motivated Individuals: Build projects around motivated individuals,
provide them with the environment
and support they need, and trust them to get the job done.
•Face-to-Face Communication: The most efficient and effective
method of conveying
information is face-to-face conversation.
•Working Software: Working software is the primary measure of
progress.
7
Continuation
•Sustainable Pace: Agile processes promote sustainable development.
Teams should be able to maintain a constant pace indefinitely.
•Technical Excellence: Continuous attention to technical excellence
and good design enhances agility.
•Simplicity: The art of maximizing the amount of work not done
essentially focusing on simplicity is essential.
•Self-Organizing Teams: The best architectures, requirements, and
designs emerge from self-organizing teams.
•Reflection and Adjustment: At regular intervals, the team reflects on how
• to become more effective and adjusts its behavior accordingly.
8
•Iterative Development:
Key concepts of Agile:
Agile projects are broken down into small, manageable units called iterations
or sprints, usually lasting 1-4 weeks. Each iteration results in a potentially
shippable product increment.
•Incremental Delivery:
Instead of delivering the entire product at once, Agile teams deliver small,
working parts of the product at regular intervals. This allows for early and
continuous delivery of value.
•Collaboration and Communication:
Agile encourages close collaboration among all stakeholders, including
developers, testers, product owners, and customers. Daily stand-up
meetings, often called "scrums," are a common practice to keep everyone
aligned and informed.
•Customer Feedback:
Agile relies on constant customer feedback. By involving customers
throughout the development process, Agile ensures that the final product
meets their needs and expectations.
•Flexibility and Adaptability:
Agile methodologies welcome changes in requirements, even late in the
project. This flexibility allows teams to adapt to new information and
9
ITIL:
ITIL is Information Technology Infrastructure Library, where both
ITIL and Devops both frameworks focus on improving IT service
management and software development practices.
The Key difference between ITIL and Devops is, ITIL provides a
comprehensive framework for IT service management, while
DevOps focuses on improving collaboration and efficiency in
software development and deployment.
Also the scope of ITIL is more towards broader IT service
management within large organizations and where as DevOps
more towards agile and dynamic environment.
11
Why DevOps?
What is CI?
The enablement of multiple people working together without affecting the
original deployed application is called CI
And CD?
Continuous Delivery is a practice where code changes are automatically
built, tested, and prepared for release to production.
Continuous Deployment takes Continuous Delivery one step further by
automating the deployment of every code change that passes through
the pipeline directly to production.
13
Continuation:
DevOps: DevOps emphasis strongly on automation across the entire delivery
pipeline. This includes automated testing, continuous integration, continuous
deployment, and infrastructure automation. Tools like Jenkins, Docker, Kubernetes,
and Ansible are central to the DevOps approach.
End-to-End Delivery:
• Agile: Focuses on the development phase, ensuring that small increments of
software are delivered frequently and that the team can adapt to changes in
requirements.
• DevOps: Takes an end-to-end view of the software delivery process, ensuring that
the software can be developed, tested, deployed, and monitored continuously. It
addresses the entire lifecycle from code commit to production deployment and
beyond, with a focus on minimizing downtime and increasing the reliability of
releases.
15
Continuation:
16
Delivery Pipeline
17
Continuation
19
Tools in DevOps
21
Why tools ?
Git: To store different versions of an application
Maven, Gradle: Build tools to take code from different repos & builds a
complete application
Automation(scripted) testing tools: Se, Junit for software quality
Jenkins: This is an open-source solution comprising an automation server to
enable continuous integration and continuous delivery (CI/CD), automating the
various stages of software development such as test, build, and deployment.
Tools that control and manage the deployment of code in prod env: xebialabs,
bms
Once software is deployed ops team configure servers, provision them with
required resources : docker, k8s
Monitoring - Spying on the issues: Nagios
22
Continuation:
Disadvantages: Monolithic applications can be quite effective until they grow too
large and scaling becomes a challenge.
Slower development speed : If application is too large
Scalability – You can’t scale individual components.
Reliability – If there’s an error in any module, it could affect the entire application’s
availability.
Barrier to technology adoption – Any changes in the framework or language affects
the entire application, making changes often expensive and time-consuming.
Lack of flexibility – A monolith is constrained by the technologies already used in the
monolith.
Deployment – A small change to a monolithic application requires the redeployment of
the entire monolith.
24
Microservices Architecture:
A microservices architecture, also simply known as microservices, is an
architectural method that relies on a series of independently deployable
services.
These services have their own business logic and database with a specific
goal. Updating, testing, deployment, and scaling occur within each service.
Microservices decouple major business, domain-specific concerns into
separate, independent code bases.
Microservices don’t reduce complexity, but they make any complexity visible
and more manageable by separating tasks into smaller processes that
function independently of each other and contribute to the overall whole.
25
Continuation:
Advantages:
Agility – Promote agile ways of working with small teams that deploy
frequently.
Flexible scaling – If a microservice reaches its load capacity, new instances
of that service can rapidly be deployed to the accompanying cluster.
Continuous deployment – We now have frequent and faster release cycles.
Highly maintainable and testable – Teams can experiment with new
features and roll back if something doesn’t work.
High reliability – You can deploy changes for a specific service, without the
threat of bringing down the entire application.
26
Continuation:
Disadvantages:
Debugging challenges – Each microservice has its own set of logs, which
makes debugging more complicated. Plus, a single business process can run
across multiple machines, further complicating debugging.
Exponential infrastructure costs – Each new microservice can have its own
cost for test suite, deployment playbooks, hosting infrastructure, monitoring
tools, and more.
Lack of clear ownership – As more services are introduced, so are the
number of teams running those services. Over time it becomes difficult to
know the available services a team can leverage and who to contact for
support.
27
Continuation:
Continuous Delivery and Integration
CI/CD Pipelines: Implement Continuous Integration and Continuous Delivery
(CI/CD) pipelines to automate testing and deployment. This ensures that
changes are deployed quickly and reliably.
• Scalability and Elasticity
Horizontal Scaling: Design the system to scale horizontally by adding more
instances rather than vertically increasing the size of a single instance.
29
Continuation
• Security:
Zero Trust Architecture: Adopt a zero-trust approach where all access is
authenticated and authorized, regardless of the origin of the request.
Monitoring and Observability:
Full-Stack Monitoring: Implement end-to-end monitoring across all services
and infrastructure components to detect issues early and respond quickly.
Decentralized Governance:
Empower Teams: Decentralize governance by allowing teams to choose the
best tools and practices for their specific needs, within the bounds of
organizational standards.
30
Continuation:
Use of Containers and Orchestration:
a. Containerization: Use containers to package applications and their
dependencies consistently across different environments.
b. Orchestration: Implement container orchestration platforms like
Kubernetes to manage containerized applications at scale.
Feedback Loops and Continuous Improvement
Rapid Feedback: Ensure that feedback loops are short and continuous,
enabling quick identification and resolution of issues.
31
Introduction to Git
What is version control system?
A Version Control System (VCS) is a tool or software that helps track changes
to files and directories over time. It helps developers to manage different
versions of files, and revert to previous states if needed.
Two main types of VCS: centralized and distributed
Centralized example: SVN(SubVersion) CVS(Concurrent Version System)
Distributed example: Git, Bitbucket, gitlab
Source Code Management (SCM)?
Source Code Management (SCM) is a broader term that encompasses the
management of source code files, including version control. It involves
practices and tools for managing, organizing, and tracking changes to source
code throughout its lifecycle.
Github: An online platform to host our folders/repos online
32
Drawbacks: A B C
If we lost central repo the project code is gone
There can be conflict errors where for example: both developers A, B makes
Remoteto keep.
changes to same code System doesn’t know which updates
repos
Distributed VCS Push
Pull
Index or
This is a three tier architecture. Add, Staging
comm area
Several drawbacks of centralized vcs are solved here. it
merge
Developers can work together A
Automatic backups
Helps to track changes in the code
33
Continuation:
Tracking the changes: It allows to track all changes, details like who committed,
and what are the specific lines added or deleted to the codebase which helps
developers to easily review previous versions, also helps in tracing back origin of
bugs, in which they can easily revert back if changes are not required.
Working Together: The Source code control helps in multiple developers to work
along simultaneously without overwriting each other changes, that allows different
team members to add new features, fixing bugs also ensuring the collaboration to
run without hectics.
CI/CD: Version control systems often integrate with tools that facilitate code
reviews and pull requests. This allows developers to collaborate more effectively
by reviewing each other's code, ensuring higher quality and more maintainable
software.
35
Continuation:
If the central server goes down, entire codebase cannot be accessed, neither
comitted nor retrieved.
Also C-VCS is slower because every operation is based on central server and has
limited offline capabilities.
Also conflict resolution is manual
But the centralized VCS is helpful for managing backups and policies easily
Distributed Version Control System:
D-VCS as a famous example git is created by Linus Torvalds for the development
of the Linux kernel, Git became revolutionary for its distributed model, allowing
every developer to have a complete copy of the repository. This enabled
branching, merging, and collaboration on a massive scale.
37
Continuation:
Pros and Cons of D-SCM: D-SCM is fault tolerant, since any copy of repo can be
used if main server crashes and local operations like review history of commits
are faster which does not require internet access. But cons can be issue of
more disk space for projects.
Modern SCM and Cloud Integration: This can be considered with examples of
the existing platforms like GitHub, GitLab, and Bitbucket which are integrated
version control systems with cloud-based services, enabling collaboration,
code reviews, continuous integration (CI), and project management.
The main difference between Distributed and Modern SCM is that, there are
limited tools for automation in D-SCM where are there are built in CI/CD
pipelines, automated tests and deployment tools in modern SCM
38
Continuation:
Code Migration: Updating or porting code to run on a different
platform or framework. This can involve refactoring code to be
compatible with a new version of a programming language or
library.
Database Migration: Moving a database from one system to
another that can involve data transformation, schema changes
also ensuring data integrity.
SCM systems here, keep track of different versions of the code,
which helps in ensuring that the code being migrated is the
correct version and includes all necessary changes.
40
Shared Authentication:
Shared Authentication refers to use the single authentication
mechanism or service to provide access to multiple applications
or systems.
This approach simplifies the user experience by allowing users to
log in once and gain access to various services without needing
to authenticate separately for each one
Single Sign On: SSO is a common implementation of shared
authentication which allows users to authenticate once and gain
access to multiple applications or services without the need for log
in separately for each one. This happens via authentication token or
a session creation when user logs in This token is then used to
access other applications or services that are part of the SSO
41
Continuation:
Another way is Centralized Authentication Providers:
Centralized authentication providers manage user identities and
authentication across multiple systems or services from a single point of
control. This centralization helps streamline user access, improve security, and
simplify administration. Examples are Identity Providers like: LDAP, Oauth etc.,
LDAP: LDAP is lightweight Directory Access Protocol, where LDAP directories are
organized hierarchically with entries structured in a tree format. Each entry
represents an object (example: user, group) and has attributes (example:
username, email).
LDAP supports various operations, such as searching for entries, reading
attributes, adding new entries, modifying existing entries, and deleting entries.
Users authenticate by binding to the LDAP server with their credentials. The
server verifies these credentials and returns an authentication response.
42
Continuation:
Oauth:
The Oauth is Open Authorization is generally used to grant the third
party applications with limited permissions without exposing the
user’s credentials
Generally for example there will be a third party app requesting
access, and there is authentication server that issue access tokens
after authenticating the user and granting consent. And also a
resource server, that hosts the protected resources and accepts
access tokens to grant access.
Authentication request->User Consent->Authorization code-
>Access code->Resource access.
43
Continuation:
Allows users to host static websites
Provides a marketplace for third-party integrations and applications to extend
GitHub’s functionality.
GitHub Actions enables CI/CD workflows, allowing automated testing, building,
and deployment of code.
BitBucket:
This is known for its integration with Atlassian tools.
Bitbucket Pipelines is a CI/CD service integrated into Bitbucket, providing
automated build, test, and deployment capabilities.
Provides issue tracking with support for issue management and integration with
Jira.
Facilitates code review with pull requests and inline comments.
46
Continuation:
GitLab:
This is similar to GitHub’s pull requests, GitLab’s merge requests facilitate code
review and discussion. And also hosts Git repositories with features for version control
and collaboration.
GitLab positions itself as a complete DevOps lifecycle tool. It integrates various
stages of software development, from planning and coding to testing, deployment,
and monitoring, into a single application. GitLab provides a suite of tools for
monitoring, security, and infrastructure management, including features for container
management and Kubernetes integration.
Whereas, GitHub’s primary focus is on source code management and collaboration. It
provides robust features for version control, code review, and collaborative
development. GitHub Actions to provide CI/CD capabilities in github, While GitHub has
strong CI/CD capabilities, it relies on integrations with third-party tools for certain
DevOps functionalities.
47
Git Architecture:
Working Local staging Remote
directory area Local Repository
Repository
git add
git
commit Push to
remote repo
git pull
git checkout
git
merge
Git merge- after you are done with all changes you can merge the new
branches to master branch
48
The git init command initializes a new Git repository. Here’s what happens
when you run git init:
Details:
Create a New Git Repository: It sets up a new Git repository in the current
directory,
Allowing to start tracking changes to files in that directory.
Create a .git Directory: A hidden directory named .git is created in the root of
your project.
This directory contains all the metadata and objects needed for version
control, including:
Configuration Files: Settings for the repository, such as user information and
remote repositories.
Commit History: Logs of all commits and changes made to the repository.
Branches and Tags: Information about different branches and tags within the
repository.
Objects and Index: Data files and the index (staging area) used to track changes.
This initializes basic git structures such as default branch main or master to
start accepting commits
The adding files to staged area can be done using git add and commit
49
Let’s practice:
Gitbash download: https://git-scm.com/downloads
Creating the organization - https://github.com/settings/organizationsGit
Commands:
* git init – initializes the empty git repo(the .git file is created that stores history of
changes made)
Little Theory
Fast Forward merge occurs when branch that is
merging(newbranch) is directly ahead of branch we are merging
(master), then master can simply move forward to include the
new commits without creating a new commit. This happens when
there are no diverging changes between the branches.
A merge commit has two parent commits: one from the the
master branch and one from the newbranch This commit
represents the point where the branches are combined Git
creates a new commit (called a merge commit) to combine the
histories of both branches. This happens when When a fast-
forward merge is not possible because both branches have
diverged
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Docker 77
Installation steps:
Installing wsl in windows:
Open PowerShell or Windows Command Prompt in administrator mode by right-clicking and
selecting "Run as administrator",enter the below command, then restart your machine.
wsl –install: This command will enable the features necessary to run WSL and install the Ubuntu
distribution of Linux
curl -fsSL https://get.docker.com -o get-docker.sh
DRY_RUN=1 sudo sh ./get-docker.sh
sudo service docker start
sudo service docker status
sudo curl -SL https://github.com/docker/compose/releases/download/v2.11.2/docker-compose-linux-
x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo docker-compose version
79
Before Docker:
Each developer needs to install and configure all the services directly on their
OS of their local machine.
Drawbacks: Installations versions differs in each OS
Many steps, may go wrong during installation
Application dependent services are all needed to be installed by the developer
After Docker:
It has own isolated environment
Packages any service with all the dependencies
Starts the service with 1 docker run command, and this command is same for
all the OS and all the services.
Ex: docker run redis
81
How is OS ?
OS has mainly 2 main layers OS Application layer
Hardware layer
82
Differences
Docker Containers:
84
85
86
87
A dedicated team is responsible for reviewing and publishing all the content
in docker official image repositories. Which has security experts and software
maintainers.
This collaboration happens openly in github which enables anyone to
participate.
Examples:
Dockerhub is a largest public registry, anyone can search and download
required docker images. It also enables to host both public and private repos
of the applications
Private registries need prior authentication, example: ECR(Amazon elastic
container registry), google cloud container registry, azure container registry,
Registry Vs Repository?
Registry is a service that provides storage for storing different repositories.
While the repository is the collection of similar images of different
versions/tags.
88
Dockerfile creation:
FROM: Docker files start from a parent image or base image and we choose this base
image depending on which tools we need
WORKDIR: specify a working directory inside the container where commands will be
executed.
COPY: Copy files from host to image by COPY instruction
RUN: Run will execute any command in a shell inside the container environment
CMD: the instruction that has to be executed when docker container starts, there can be
only one CMD
Each instruction in the docker file creates one layer in the docker image.
FROM <base_image>:<tag>
WORKDIR /path/to/directory
COPY <src> <dest>
RUN <command>
CMD [“executable”, “server.js”] (executable can be: node, python etc...,)
> docker build –t <image-name>:<version/tag> .
89
Commands:
>docker pull <image>
>docker images
>docker run <imagename>:<tag>
>docker ps (shows running containers)
>docker ps –a (shows all including stopped containers)
Generally the containers ports are not exposed to the host and are only exposed
inside the docker network. So to access the application or make service available to
outside hosted by specific container, port binding of that docker container’s port and
host machine’s port needs to be done.
>docker stop <container-id>
-d (detach mode), -p{host port: container’s port} (publish container’s port to host)
>docker run –d –p {host port: container’s port} <imageid>:<tag> --name
<container-name>
>docker logs <containerId>
90
Continuation:
Therefore, dockerd is responsible for,
Build and Management of container images
Handling container lifecycle
Network configurations
Data Volumes
Container RunTime(Containerd):
This is a container runtime that directly interfaces with the Linux
kernel features (cgroups, and namespaces) to create and manage
containers. It handles all the low-level details of managing the
container lifecycle. (create, execute, delete), networking etc
94
Differences:
Dockerd(Docker Daemon) Containerd(Container Runtime)
Higher-level management of Docker Low-level management of container
containers, images, volumes, networks, lifecycle (running, stopping, deleting
and registries. containers).
Used as Full Docker platform. Core container runtime, can be used
Communicates with containerd to run standalone or with Kubernetes.
and manage containers and with Communicates with the Linux kernel
Docker clients for container and interacts with dockerd or other
management. orchestrators
Full lifecycle management including Container runtime only, focused on
images, build, volumes, networks.
low-level container operations.
95
Kubernetes:
Kubernetes is a container orchestration
technology used to orchestrate the
deployment and management of
hundreds and thousands of containers
in a clustered environment.
The process of automatically deploying
and managing containers is known as
Container Orchestration.
Under circumstances where an
application relies on other containers
such as database or messaging services
or other backend services or when the
number of users increase/decrease, the
application needs to be scaled up/down
and for this an underlying platform with
a set of resources will be required.
96
Advantages of K8S:
• Due to the multiple instances running on different nodes, an application will
now be highly available as hardware failures do not bring the application down.
• User traffic is load balanced across the various containers.
• More instances of the application can be seamlessly deployed when demand
increases, and the number of nodes can be scaled up/down without having to
take down the application when hardware resources are depleted.
K8S Architecture:
• A Node is a worker machine in Kubernetes, interchangeably called as Minion. It
is the smallest unit of computing hardware in Kubernetes and will likely be
either a physical machine in a datacenter or virtual machine hosted on a cloud
provider.
• A Cluster is a set of nodes that run containerized applications. Cluster
intelligently handles distributing work to the individual nodes, and will shift
around work as necessary if any nodes are added or removed from the cluster.
98
99
The Master is another node with Kubernetes installed in it, and is configured
as a Master. The master watches over the nodes in the cluster and is
responsible for the actual orchestration of containers on the worker nodes.
A POD is a single instance of an application and the smallest object that can
be created in Kubernetes. The ultimate aim of using Kubernetes is to deploy
an application in the form of containers on a set of machines that are
configured as worker nodes in a cluster. Kubernetes does not deploy these
containers directly on the worker nodes, but encapsulates the containers into
PODs.
100
https://github.com/mmumshad/kubernetes-training-answers
101
Commands:
102
103
104
105
Continuation:
It also helps in automatically managing of dependencies between the
components, ensuring that files are compiled in the correct order and
that all necessary libraries are included.
Examples of Build Systems are :
Apache Ant: A Java-based build system that uses XML files for
configuration, making it highly flexible and extensible.
Maven: Also Java-based, Maven goes beyond compilation to manage
project dependencies, documentation, and site deployment.
Gradle: A modern build system for Java and other languages that
combines the best features of Ant and Maven with a Groovy-based DSL
for configuration.
Maven 107
Before Maven:
Need of adding jars
Minor mistake the servlet structure does not give right output
Build and deploy takes lot of time
After:
Maven is a automation tool that helps in build and manage projects in short time.
It is a product from apache that uses a process called pom.xml(project
object model)
Pom.xml has information about the project details, configuration, plugins
and dependencies, this can be created by maven architype
we get from maven central repository
Users has to only declare dependency requirements, maven will download
and deploy the dependencies with applications.(needs jdk latest)
Maven practice: 108
Linux Env:
wget
https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz
~> download maven repo
tar –zxvf <file-name> ~> unzip
ll ~>check contents
cd <foldername>, ll
sudo amazon-linux-extras install java-openjdk11 ~>download jdk
yum install maven –y ~> maven package install from repo
java –version , maven –version ~> version check
mvn archetype:generate ~> mvn recources download
GroupId: project name
Artifactid: package name(this has final code ex: devops)
This has pom.xml, src (main, test)
ls src/main/java/batch/
>ll
>ls /target/classes/batch ~> has app.class file(class file generated)
>mvn test
>mvn package ~> jar file creation
>mvn install ~> to place the the jar file in local repo
>mvn deploy ~>deploying into artifactory
Java: sudo amazon-linux-extras install java-openjdk11
110
Windows:
https://dlcdn.apache.org/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.zip
~installation
Add path to user variables, MAVEN_HOME, M2_HOME, also needs jdk
Add bin path to system variable path
>mvn –version or mvn -v
>mvn archetype:generate ~>creates project from existing template, downloads plugins if
not found, there are many archetypes we can chose a template by number version
choose, groupId : unique (ex: com.hello), artifactId: name of the project(this has src,
pom.xml), version(dev)
If jar/war file is created it will be with name: artifactId-version.extension (ex: my-maven-
prjct-1.0-SNAPSHOT.jar) package name: here class, test dirs are created.
<follow the same steps>
Maven lifecycle: 111
Commands:
yum install java-1.8.0-openjdk –y
yum install maven –y
yum install git –y
git clone <maven-repo>
Cd <dirname>
mvn validate : validates the syntaxes
mvn compile : .class file, target file is generated,
mvn test : testing before converting to jar file
mvn package : creating a jar/war file
mvn install : stores in local repo(.m2)
mvn deploy: deploys to artifactory
(If you are installing any webapplication jar file it can be copied into tomcat
webapps folder to run the webapplication on your system)
112
Continuation:
Jenkins software’s helpful to track and monitor repetitive
activities that emerge throughout a project’s development. For
example, Jenkins will continually test your builds and alert you to
any mistakes early in the process, when a team is working on
that project.
It is useful for deploying the code into production
It helps in automating the workflows, for example automating the
installation upgradations in less time reducing the errors.
The troubleshooting is easy since , when Jenkins tasks run, they
collect console output from stdout and stderr parameters.
114
Jenkins Plugins:
Plugins are available on Jenkins that equips it with additional features or
functionalities you require in the SDLC.
There are several plugins that helps in extending its efficacy by integrating
Jenkins with every tool present in the DevOps toolchain to ensure CI/CD.
Jenkins plugins are written in Java and use the same Jenkins API. Each plugin runs
within Jenkins, extending its capabilities without modifying Jenkins core code.
Plugins can be installed directly from the Jenkins UI (Manage Jenkins > Manage
Plugins)
Examples for Jenkins Plugins:
Git: Git is one of the most installed Jenkins add-ons available on its repository. It
allows you to integrate Jenkins with GitHub and transfer GitHub repository data
to the Jenkins machine easily.
116
Continuation:
Build Tools Plugins: Example: Maven Integration Plugin is used to provide support
for building Java projects with Maven.
Docker Plugin: The Docker plugin enables you to create Docker containers and
automatically run builds on them.
Jira Plugin: The Jira plugin integrates Jenkins with Atlassian Jira Software. The Jira
plugin enables you to get better visibility into the development pipeline.
Kubernetes: With this plugin, you can automatically scale the running process of
Jenkins agents in the Kubernetes environment.
SonarQuobe: This offers necessary security feedback at the time of code review.
And there are many like these around 1400 plugins.
117
Continuation:
In CI/CD , the continuous integration involves. Devolopment,Code
and Build and Test.
While CD is the continuous delivery that involves steps like
building the docker image, push it to repository, adding to the
K8s file and Deploying
With Jenkins we can build this pipelines to involve these and
automate the process, that speeds up development process.
118
Host Server:
In Jenkins, the host server (also referred to as the Jenkins Master or
Controller) is the main server that orchestrates the Jenkins pipeline,
manages jobs, schedules builds, and coordinates with build slaves (agents)
in a Jenkins environment.
The host server is responsible for managing all Jenkins jobs and builds,
including creating, configuring, and monitoring them.
The Jenkins Master schedules jobs to run on available agents (slaves) based
on job configurations, labels, and resources.
When multiple builds are requested, the host server places them in a build
queue.
It allocates builds from the queue to agents as they become available.
119
Continuation
The master server keeps track of the available resources on each agent and assigns builds
accordingly.
The Jenkins master manages all plugins and their configurations, including installations, updates,
and removal.
The Jenkins master server stores all job configurations, plugin configurations, user settings, and
security settings.
The master is responsible for handling HTTP/HTTPS requests and acts as a web server for the
Jenkins UI.
The Jenkins master handles authentication, authorization, and security settings.
The Jenkins master is responsible primarily for job orchestration, job scheduling, and providing the
user interface.
Therefore the host server i.e Jenkins Master is central to the Jenkins system, managing and
coordinating all CI/CD activities. It controls jobs, agents, build queues, security, and plugins,
providing a centralized environment for orchestrating and automating development workflows.
120
Build Slaves
A Slave is a Java executable that runs on a remote machine.
It hears requests from the Jenkins Master instance.
Slaves can run on a variety of operating systems.
121
Continuation:
Jenkins checks the Git repository at periodic intervals for any
changes made in the source code.
Each builds requires a different testing environment which is
not possible for a single Jenkins server. In order to perform
testing in different environments, Jenkins uses various
Slaves as shown in the diagram.
Jenkins Master requests these Slaves to perform testing and
to generate test reports.
We can create the nodes on Jenkins and run the job on the
respective node
122
Jenkins uses these tools to perform tasks like pulling code from Git, building it
with Maven, testing it with JUnit, and packaging it into deployable formats.
If builds run on separate nodes, those nodes also need the required software
installed.
Depending on the project, Jenkins requires appropriate runtimes to build and run
code:
Java (JDK) for Java applications.
Node.js for JavaScript-based projects.
Python, Ruby, PHP, or other interpreters for specific language needs.
Software for compiling and packaging applications:
Maven/Gradle: For Java-based projects.
npm/yarn: For JavaScript applications.
Docker: If Jenkins is used to build and deploy Docker containers.
Kubernetes CLI (kubectl): For deploying to Kubernetes clusters.
Using Docker for builds ensures a clean, reproducible environment with all
dependencies included.
124
Triggers
There can be various kinds of triggers.
A user manually starts the build by clicking the "Build Now" button
on the Jenkins dashboard.
Jenkins periodically checks the version control system (e.g., Git or
SVN) for changes. If new changes are detected, a build is triggered.
One job can trigger another job as part of a multi-step process in
Upstream/Downstream triggers.
Useful for linking jobs in a pipeline or dependency chain.
Builds can be initiated via an external script or system using an
HTTP API, these are called Remote Triggers.
125
Build Pipelines
A build pipeline represents an entire workflow, connecting all
stages of the software lifecycle, from building to testing to
deploying, in one cohesive process.
Pipelines are defined using a Jenkinsfile, which provides more
flexibility and better control
Here, in all stages (build, test, deploy, etc.) are written in a
single script.
Pipelines can run tasks sequentially or in parallel.
This offers better error handling, retries, and visualization
compared to job chaining.
129
Creating a Pipeline
Declarative Pipeline: This is a more structured and simpler syntax
for writing pipelines.
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building the code...'
sh 'mvn clean install'
}
}
130
Continuation:
stage('Test') {
steps {
echo 'Running tests...'
sh 'mvn test'
}
}
stage('Deploy') {
steps {
echo 'Deploying application...'
sh './deploy.sh'
}
}
}
}
131
2.Automated Builds:
The server compiles the code into a functional application,
ensuring consistency in how the code is built across
environments.
3. Automated Testing:
After the build, the server executes predefined tests (e.g.,
unit tests, integration tests) to validate the code.
4. Deployment:
Upon successful builds and tests, the server can deploy the
application to staging or production environments.
Example: Jenkins is an open-source and highly customizable
build server.
134
Infrastructure as code:
Infrastructure as a code is a method of managing and provisioning
computing resources like servers, networks, and database, using
machine-readable configuration files.
Instead of manually setting up infrastructure, IaC allows developers to
automate the process, treating infrastructure like software code.
IaC Working as follows:
1. Configuration Files:
Infrastructure settings are defined in text files using tools like YAML,
JSON, or HCL (HashiCorp Configuration Language).
These files describe the desired state of resources, such as virtual
machines, storage, or networking.
136
2. Execution:
Tools like Terraform or Ansible interpret the configuration files and
automatically create or modify resources to match the desired
state.
3. Repeatability:
The same configuration file can be used to recreate identical
environments, ensuring consistency.
IaC Tools Examples:
Terraform: Works with multiple cloud providers (AWS, Azure, GCP).
Ansible: Focuses on configuration management and application
deployment.
137
Benefits of IaC:
Automation: Eliminates manual configuration, saving time and
reducing errors.
Version Control: Infrastructure code can be stored in Git
repositories, enabling collaboration and rollbacks.
Scalability: Makes it easy to scale resources up or down as
needed.
Use Cases:
Creating and managing cloud infrastructure for applications.
Managing multi-cloud environments.
Automating deployment alongside application code.
138
Building by dependency
order:
To build projects in dependency order in Jenkins, you need to
define a structure that respects the order in which dependent
modules or projects are built.
The approach is as follows:
1. Analyze Dependencies
Identify all project modules and their dependencies. For example,
if Module A is required by Module B and Module C, ensure Module
A builds first.
Use tools like mvn dependency:tree or other dependency analysis
tools based on required stack.
140
steps { }
build job: 'Module-A-Job' }
}
} }
}
142
3. Parallel Builds:
Modules without dependencies can be built in parallel to save time.
4. Build tools for dependency management:
Maven/Gradle: Configure dependencies in the build file to automate
the build order. Jenkins can invoke the build tool
NPM/Yarn: Use dependency trees to determine build order in
monorepos.
5. Add Error Handling and Notifications
Ensure any failure in the dependency chain is captured and
communicated.
6. Store Configuration in Jenkinsfile
Keep your pipeline code in a Jenkinsfile within your version control
system. This ensures consistency and versioning for build logic.
143
Checkout phase:
This purpose is to retrieve the source code from a version control system (e.g., Git,
Subversion).
This process involves connecting to the repository using the configured credentials,
fetching the specified branch, tag, or commit. And then Place the source code into the
workspace for the build.
The common tools we use in checkout phase are Git, SVN, Bitbucket, or GitHub plugins
etc.,
145
pipeline { }
agent any }
environment { }
MAVEN_HOME = '/opt/maven' // post {
Path to Maven installation success {
PATH = "${MAVEN_HOME}/bin:$ echo 'Build completed
{env.PATH}" // Add Maven to PATH successfully!'
} }
stages { failure {
stage('Build') { echo 'Build failed. Check the
steps { logs for details.' }
script { }
echo 'Starting Build }
Process...'
sh 'mvn clean'
sh 'mvn package -
DskipTests'
archiveArtifacts
artifacts: 'target/*.jar', fingerprint:
true
}
147
Steps Involved:
Run unit tests, integration tests, and functional tests.
Capture and analyze test results.
Generate and publish reports (e.g., JUnit, TestNG).
Common Tools: JUnit, Selenium etc.,
pipeline {
stages {
stage('Test') {
steps {
sh './gradlew test'
}
}
}
}
149
The way GitLab CI/CD works is that, Pipelines are configured using a .gitlab-
ci.yml file in the project. It integrates seamlessly with GitLab repositories and
triggers pipelines on push, merge, or tag events.
The features are it is built-in CI/CD within GitLab (no need for external tools)
and also it has strong integration with GitLab's issue tracking and version
control and it supports Docker-based builds and deployment.
3. CircleCI:
CircleCI is a cloud-based CI/CD platform that automates build, test, and
deployment workflows.
This is configured using a config.yml file stored in the .circleci directory of the
repository. Both cloud-hosted and on-premises options are available, and a
vast ecosystem of plugins and integration points enables CircleCI to work with
any Git-based repository and integrate with a wide range of deployment
targets.
152
4. Team City:
TeamCity is a CI/CD tool developed by JetBrains, known for its
robust features and strong IDE integration.
It provides a web-based interface to configure and manage build
pipelines.
It integrates with popular version control systems and build tools.
5. Azure DevOps:
Azure DevOps is a comprehensive suite of development tools
offered by Microsoft, including CI/CD pipelines.
Pipelines are defined using YAML files or configured via the Azure
DevOps interface.
This is best for enterprises using Microsoft technologies and
Azure cloud.
153
6. Atlassian Bamboo
Bamboo is Atlassian's highly customizable continuous integration tool
that is comparable to Jenkins, in that it is distributed as locally
installable software with which organizations can manage their CI/CD
builds on in-house servers.
Here Projects are managed via an intuitive web interface.
It can link builds to Jira issues and Bitbucket pull requests.
Its key features are
end-to-end visibility across the development lifecycle.
Native integration with Atlassian tools.
Strong support for branching and merging workflows.
7. CloudBees CI:
This is an extended version of Jenkins tools to expand the CI efforts.
154
2. Testing:
We can perform functionality through unit, integration, and system tests. And
the tools here we use are Junit/TestNG for Java testing frameworks and
selenium for automated testing for web applications.
3. Security Scanning:
The objective is to identify vulnerabilities in the application and dependencies.
The tools or plugins we use are like OWASP Dependency-Check which
scans for known vulnerabilities in libraries, Synk that helps in monitoring
dependencies for security issues. etc.,
We implement this by adding a step to run security scans during the pipeline.
4. Performance Testing:
This objective is to evaluate application responsiveness and stability under
load.
157
iii. System Testing: This is used to evaluate the whole system. The
objective of this system testing is validate the software.
For example testing an e-commerce application to ensure users can search
for products, add them to the cart, and complete the checkout process.
2. Non-Functional Testing:
Non-functional testing evaluates the performance, usability, and reliability of
the software rather than its specific functionalities.
i. Performance Testing: This assesses the speed, responsiveness, and
stability of the software under various conditions.
The objective is to ensure the application can handle expected workloads
efficiently.
For example measuring the time taken to load a webpage under normal
and peak user traffic.
161
ii. Load Testing: The focus of this is to evaluates the application under expected
and maximum load conditions. This is used to determine the maximum number of
users the system can support.
Example: Testing a web server to see how many concurrent users it can handle.
iii. Stress Testing: This Tests the system beyond its normal operational capacity.
This assess the system's robustness and its ability to recover from failure.
Example: Simulating a sudden spike in user activity to observe system behavior.
iv. Scalability Testing: Here this determines the software's ability to scale up or
down as needed. It ensures the application can handle growth in user base or data
volume.
Example can be testing a cloud-based application for its capacity to add new
servers dynamically.
v. Security Testing: This help in identifying vulnerabilities in the software. The
objective is to protect data and ensure the application is resistant to attacks.
Example, testing for SQL injection vulnerabilities in a database.
162
Automation reduces the likelihood of human error during test execution. It ensures
tests are executed exactly the same way every time.
Test scripts, once created, can be reused across multiple versions of the software.
Automation allows for broader coverage, including edge cases that manual testers
might overlook.
Automation supports continuous integration pipelines, providing immediate
feedback on code changes.
Although the initial costs are high, automation reduces long-term manual testing
expenses.
Disadvantages of Test Automation:
The initial costs are high like buying licenses for enterprise testing tools like UFT or
training the team on Selenium.
Automated scripts require frequent updates to align with changes in the application
or environment, for example a small feature change in UI needs reworking multiple
test cases
165
Writing complex test scripts for API testing may require advanced
programming skills, so sometimes automation demands a certain level
of expertise which is challenging for teams with limited experience.
Creating automated test scripts can be time-consuming, delaying initial
testing efforts.
Selenium Framework:
Selenium is a automation testing framework which is an open-source
that enables users to automate web applications across different
browsers and platforms.
It supports multiple programming languages, including Java, Python,
C#, Ruby, JavaScript
Selenium is highly extensible and forms the backbone for many test
automation frameworks.
166
167
3. Selenium WebDriver:
This WebDriver is a powerful and flexible api for creating, executing test scripts across
multiple browsers. Also this supports advanced programming features like loops,
conditions and other external configurations.
It provides cross-platform and cross-browser testing capabilities.
It can be able to work seamlessly with browsers such as Chrome, Firefox, Safari, and Edge.
This Selenium webdriver is introduced as selenium 2.0 and is successor of Selenium
Remote Control, consisting of API, Library, Driver, and Framework that work together to
enable test execution.
This webdriver has four different components:
i. Selenium Language Bindings or Client Libraries:
The language bindings or client libraries support multiple programming languages like
Java, Python, C#, and JavaScript. These libraries are jar files that contain Selenium
WebDriver classes and methods needed for automation test scripts.
Selenium client libraries are not a testing framework, but rather an application
programming interface (API) for running Selenium commands from within the program.
169
ii. JSON Wire Protocol: JSON means JavaScript Object Notation that supports
data interchange formats in languages like Java, C#, Python, Ruby, etc. It helps
to exchange data between the client and server on the web.
iii. Browser Drivers: This acts as a act as a bridge between Selenium
WebDriver and the web browser, because selenium WebDriver doesn’t
interact directly with the browser. Instead, it communicates through a browser-
specific driver, which translates the commands from WebDriver into browser-
understandable actions.
Using the wire protocol, WebDriver implements the appropriate operations for
each browser based on the requests received from language bindings.
The communication between WebDriver and the browser driver happens using
the WebDriver Wire Protocol, where this protocol transmits JSON-formatted
commands over HTTP.
The browser driver receives these commands, and performs the necessary
actions within the browser, such as clicking a button, navigating to a URL etc.,
170
4. Selenium Grid
The Selenium Grid is a tool used with Selenium RC to execute tests parallelly
on different machines and browsers. It reduces the execution time of the
testing suite because it runs parallel execution of tests across different
machines and browsers.
It consists of two major components, a hub which is a central machine to
trigger test cases within selenium grid and other is Nodes, that execute test
cases loaded on a hub, launching on multiple machines, platforms, and
browsers.
171
JavaScript Testing
JavaScript testing ensures that JavaScript code behaves as expected in a web application.
Since JavaScript drives the dynamic and interactive features of web applications, testing
verifies that these functionalities work correctly across browsers and devices.
Importance or Significance of JS Testing:
JavaScript is responsible for tasks like form validation, real-time updates, and user
interactions. Testing ensures these tasks operate smoothly.
Identifying bugs during development prevents issues from appearing in production,
saving time and costs.
Properly tested JavaScript enhances the reliability and performance of web applications,
leading to better usability.
JavaScript can behave differently across browsers, so testing helps maintain a consistent
user experience.
174
REPL-driven development
REPL-Driven Development is an interactive and exploratory approach to
programming where you actively use a REPL (Read-Eval-Print Loop) to write, test,
and refine code in real-time.
Instead of writing a complete program and then running it to see the results, you
write snippets of code, evaluate them immediately, and get instant feedback.
This feedback loop helps you quickly identify issues, experiment with ideas, and
understand how your code behaves.
Read: The REPL reads the user’s input (a line of code or an expression).
Eval: It evaluates the input to produce a result.
Print: It displays the result of the evaluation to the user.
Loop: The REPL waits for the next input and repeats the process.
183
The REPL acts as a live coding environment where you can type code line-
by-line, test ideas, and see instant results.
REPL has Interactive coding, Instant feedback, live debugging and
incremental development that is building application step-by-step and
testing functionality.
But there are some limitations as follows:
It is not suitable for complex systems. For large applications, you need a
structured workflow with proper testing and version control.
Without proper structure and automation, relying solely on REPL can lead to
missed edge cases. Therefore it is Error Prone.
Works well for small functions or snippets but not for complex one’s therefore
there is scalability issue.
We generally use REPL :
when learning a new Language where A REPL is perfect for understanding the
syntax and behavior of a new programming language.
184
Deployment Systems:
When you deploy an application, you’re essentially transferring all the components
(like code, configuration files, and dependencies) to an environment where it can
be used such as a production server, a container, or a cloud service.
Deployment systems manage this process by automating repetitive tasks, handling
complex configurations, and monitoring the application to catch issues early.
There are several tools and deployment platforms
CI/CD Pipelines: These automate the entire deployment process example: Jenkins,
GitHubActions, GitLab CI/CD.
Containers and Orchestration: Docker and Kubernetes.
Serverless Platforms and Cloud platforms like AWS Lambda, Microsoft azure app service,
Google cloud functions
IAC tools that automate and standardize like Terraform, Ansible, Puppet and chef etc.,
186
Virtualization stacks
Virtualization stacks are systems or layers of technology that
enable multiple virtual environments to run on a single physical
machine.
These environments can be virtual machines (VMs), containers,
or other isolated workloads.
There are different kinds of Virtualization stacks like traditional
Virtual Machine Stacks like Hyper-V, Vmware
Container based like docker, Kuberenetes,
Cloud based and Serverless virtualization stacks etc.,
188
But there are challenges like browser compatibility, security concerns and
device dependence also the load time because transferring and initializing
large client-side codebases can slow down the first load of an application.
Puppet Master and Agents:
Puppet is a powerful automation tool designed to manage and configure
infrastructure. It follows a client-server model with two key components:
Puppet Master and Puppet Agents.
This structure helps to automate the management of systems, ensuring
they remain in a desired state without manual intervention.
Puppet Master: This is the central controller in the system, responsible
for managing configurations and distributing them.
Puppet Agents: These are clients or nodes (typically servers) that receive
configuration instructions from the Puppet Master and apply them to their
respective systems.
191
Puppet Master:
The Puppet Master serves as the control center where configurations are
defined, stored, and compiled. It does not directly execute tasks but
coordinates and oversees the process.
The Puppet Master holds manifests (configuration files) that define how each
system should be configured. Based on the requests from the Puppet Agents,
the Puppet Master creates a catalog that is a list of specific resources (files,
services, packages) that need to be configured on the Agent machine. And
once compiled, the catalog is sent to the Puppet Agents for execution.
It allows system administrators to manage infrastructure from a single point,
ensuring consistency across all machines.
The Puppet Master communicates with the Puppet Agents over a secure
HTTPS connection, sending compiled catalogs, while Agents report back their
status and changes.
192
Puppet Agents:
Puppet Agents are installed on individual nodes (servers or machines) that
need to be managed. They are the "clients" in this setup and handle
executing the configuration on each system.
Periodically, the Puppet Agent contacts the Puppet Master to request the
latest configuration.
Upon receiving the configuration catalog, the Puppet Agent applies the
required changes to the system—such as installing software, modifying
files, or restarting services.
After the configuration is applied, the Puppet Agent reports back to the
Puppet Master, informing it of any changes or issues.
Agents initiate communication with the Puppet Master, requesting
configuration updates. The agent checks in regularly (e.g., every 30
minutes) but can be manually triggered to request an update as needed.
193
Advantages :
It has centralized control where Puppet Master provides a single
point to manage configurations for all nodes, making system
administration simpler and more consistent.
The Puppet Master can manage hundreds or even thousands of
nodes.
Puppet automates configuration, reducing the need for manual
intervention and making infrastructure management scalable.
The Puppet Agents run configuration tasks locally, reducing the
load on the Puppet Master and allowing faster application of
configurations.
With Puppet, you can define a desired state for all your systems,
ensuring they remain consistent regardless of any changes or
194
Ansible
Ansible is an open-source automation tool used to simplify IT management tasks such
as configuring systems, deploying applications, and automating workflows.
It allows system administrators to automate repetitive actions, streamlining
operations and ensuring that configurations are consistent and scalable across an
entire infrastructure.
Ansible operates by connecting to remote machines via SSH (or WinRM for Windows)
and executing predefined tasks to configure and manage those systems.
Ansible is agentless. This means it connects to systems directly via SSH eliminating
the need for additional software on the target machines.
Ansible follows a declarative model, where you describe the desired state of a system
rather than specifying the exact steps, you tell Ansible what you want, and it ensures
the system reaches that state.
195
Chef
Chef is an open-source automation tool used for configuring and managing
servers, applications, and services across a large-scale infrastructure.
It automates tasks such as software installation, configuration management,
and system maintenance, ensuring consistency and efficiency.
It has components like follows:
Chef Server: The Chef Server acts as the central repository where
configurations are stored. It manages the cookbooks, recipes, and metadata
for each node in the infrastructure.
The Chef Client is installed on each machine (node) that you want to manage.
It communicates with the Chef Server to retrieve and apply configurations on
the node, ensuring the system stays in the desired state.
198
While we can see some differences between salt stack and chef, like
Chef uses a client-server model, where the Chef Workstation, Chef Server, and
Chef Clients interact to automate tasks. Whereas SaltStack follows a master-
minion model, where the Salt Master manages the Salt Minions and sends them
commands to execute.
Chef typically operates in a pull model, where clients request configurations from
the server. Whereas saltstack can use both a push and pull model, giving it more
flexibility in execution.
But as part of performance SaltStack is known for its speed and can execute
commands across large numbers of systems quickly, making it suitable for real-
time automation. Whereas Chef may be slower compared to SaltStack when
managing a large number of systems due to its more complex configuration
process.
As part of learning also SaltStack is eay to learn especially with its YAML-based
configuration, and is known for its straightforward setup. Because Chef uses ruby-
bases syntax having complex architecture.
203
Therefore we can say that both Chef and SaltStack are powerful
tools for automating infrastructure management having there
unique capabilities. Chef is ideal for complex environments, while
SaltStack is designed for speed and scalability, making it perfect
for real-time tasks and large infrastructures. And we can choose
anyone among according to the requirements.
Jeevitha
https://www.linkedin.com/in/kjeevitha771
[email protected]
9100090987
Thank You