Dev Ops
Dev Ops
Requirement
Initiation Planning Design
Analysis
Waterfall
Model Divided into various phases
The output of one phase acts as the input for
the next phase
AGILE
Plan Design Develop Test Release Feedback
• Agile team produces software in small amount and incrementally instead of a big large release
• Constant and better collaboration with stakeholders and continuous improvement at every stage
Developer Operations
Disadvantages
of DevOps Hard to manage adoption of new DevOps
technologies in short time
•DevOps pipeline consists of various phases, and it tries to get rid of manual
operations as much possible in these phases
•It may include one or more manual gates that require human intervention before
it proceed to next phase
Continuous Development
Continuous Integration
Continuous Testing
Lifecycle of Continuous Monitoring
DevOps
Continuous Feedback
Continuous Deployment
Continuous Operations
The project goal and plans are created
during planning.
Continuous by developers.
Integration
in the code.
Deployment
a manual gate is preferred.
Monitoring
analyzed for application performance and issues.
Feedback
experiences while browsing the application.
Infrastructure as a
Automation
code
1. Containerization
Container technologies has made an impact in the rise of DevOps. Containers are lightweight, self-
contained environments that make it easier to host and manage web applications. By 2023,
Gartner expects 70% of companies to run two or more containerized applications. As more and
more apps will be developed, DevOps will be needed to deal with the system complexities.
trends of The concept of serverless computing has emerged as a new and exciting approach to deploying
DevOps software and other services. Serverless computing removes server maintenance, system updates
workload from the developers. Serverless computing generates code for DevOps pipelines without
the need for a host to build, test, and deploy.
3. Microservices Architecture
Microservices architecture focuses on building smaller and manageable applications than a large
monolithic applications. It encourages shorter software release intervals. Along with robust DevOps
processes, it becomes easier to build applications faster.
4. DevSecOps
Building internet facing application, security becomes a major concern for organizations.
DevSecOps integrates best practices in software development, delivery, and operations with an
emphasis on security and observability, so the risks and vulnerabilities in the given applications are
reduced. DevSecOps helps to close the security knowledge gap between IT and business. It
supports the early detection of cyber risks and the reduction of costs associated with their
remediation.
trends of Low-code platforms allow you to build apps without coding knowledge. This allows non-technical
people to contribute to software development through a visual interface that manages the entire
app development process. It allows users to build their own workflows and logic by dragging and
DevOps dropping elements. This trend in DevOps speeds up the entire development and deployment
process by creating simple and user-friendly apps.
6. GitOps
GitOps is one of the ways to implement and manage Kubernetes clusters. By releasing incremental
updates, continuous delivery enables development teams to build, test, and deploy software more
quickly. It is essential that a Kubernetes continuous integration and runtime pipeline be capable of
reading and writing files to Git, updating container repositories, and loading containers. Version
control for configuration changes, as well as real-time monitoring and alerting are all possible with
GitOps, allowing the business to better manage infrastructure.
7. Infrastructure as a Code
Market Infrastructure as a Code automates resource management and provisioning by using code, instead
of using configuration tools. DevOps teams may provide and control all parts of the environment,
including VMs, operating systems, containers, application configuration, storage, networking, and
trends of
connections between multiple components, using infrastructure as code.
DevOps 8. Automation
DevOps encourages towards automation and help businesses become more efficient, responsive,
and transparent to their customers. In order to meet the increasing demands and quick software
turn around, a high level of multitasking skilled development team is expected and the only way to
achieve this is to adopt and accelerate automation. Automation of time-consuming long processes
enables development team to focus on other critical requirements.
DevOps Roles, Responsibilities, Skills
•It allows to track and work together with project team members at the same workspace.
•Developers can compare earlier versions of the code with an older version to fix the
mistakes.
Git Repository
•Repository is the storage location where all files, packages/folders are kept.
•Remote repository is on the server and local repository is on developers local PC.
•Developers works on their local repository and push their work to remote repository.
Remote Repository
Server
Remote Repository
Developer 2 Developer 3
Developer 1
Local Repository Local Repository
Local Repository
Git Installation
Follow the installation wizard and click on next next button.
Download https://github.com/git-for-
windows/git/releases/download/v2.3
7.2.windows.2/Git-2.37.2.2-64-bit.exe
GitHub
•Git clone command
Git clone •This command is used to make a copy of a repository from an existing URL. If I want a local copy of my repository
from GitHub, this command allows creating a local copy of that repository on your local directory from the
repository URL.
Command •Syntax
•$ git clone URL
Create a sample
Java Project
•Create a sample Java project
using any IDE.
Git add
Command
•Git add command
•This command is used to add
one or more files to staging
(Index) area.
•Syntax
•To add one file
•$ git add Filename
•Syntax
•To check the status of the files
•$ git status
Git Files Status
Tracked files are those files which Git knows. These are referred as tracked files. The files were present in the last snapshot,
as well as any newly staged files; they can be unmodified, modified, or staged.
Remaining files are Untracked files. Any file in the working directory that were not in the last snapshot and are not in the
staging area. When we first clone a repository, all of our files will be tracked and unmodified because Git just checked them
out and you haven’t edited anything.
As we edit files, Git sees them as modified, because we have changed them since the last commit. As we work, we
selectively stage these modified files and then commit all those staged changes
git add
Edit an existing file
rm filename
git add
(delete a file)
git commit
Git Cheat Sheet
Git Common Commands
Git Branch Command
This command lists all the branches available in the repository.
Syntax
1.$ git branch
By default, if no argument passed, Git log shows the most recent commits first. We can limit the number of log entries displayed by passing a number as an option, such as -3 to show only the last three
Git Token Setting
Login to Github.
Click on Profile Settings - Developer Settings - Personal access tokens - Tokens Classic - Generate new tokens
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
During git push command this token will be used as auth token instead of credentials.s
Class 8
Git Branching
Model
•Git Flow / Git Branching Model
•Git flow is the set of guidelines that
developers can follow when using
Git. We cannot say these guidelines
as rules. These are not the rules; it is
a standard for an ideal project. So
that a developer would easily
understand the things.
•It is referred to as Branching
Model by the developers and works
as a central repository for a project.
Developers work and push their work
to different branches of the main
repository.
Git Branches
There are different types of branches in a project. According to
the standard branching strategy and release management,
there can be following types of branches:
•Master
•Develop
•Hotfixes
•Release branches
•Feature branches
Every branch has its meaning and standard. Let's understand
each branch and its usage.
When all the targeted features are created, then it can be merged with the develop branch. Some usual standard of
the release branch are as follows:
•Generally, senior developers will create a release branch.
•The release branch will contain the predetermined amount of the feature branch.
•The release branch should be deployed to a staging server for testing.
•Any bugs that need to be improved must be addressed at the release branch.
•The release branch must have to be merged back into developing as well as the master branch.
•After merging, the release branch with the develop branch must be tagged with a version number.
Git Branches
Hotfix Branches
Hotfix branches are like Release branches; both are created for
a new production release.
The hotfix branches arise due to immediate action on the
project. In case of a critical bug in a production version, a hotfix
branch may branch off in your project. After fixing the bug, this
branch can be merged with the master branch with a tag.
Class 9
Jenkins is an open-source continuous integration tool.
Overview
plugins.
Jenkins runs these tasks each time a developer has changed the
source code, can detect any defects much faster meaning that you
maintain applications' quality and reduce time to market.
Jenkins has very large community that
contributes to it regularly.
Developer
Developer
Jenkins Installation
• Download Jenkins from https://www.jenkins.io/
• Close pop up
Class 10
Jenkins Management
• Click on the "Manage Jenkins" option from the left hand of the Jenkins Dashboard page to manage Jenkins.
• If you are working on multiple projects, you may run multiple jobs on each and every project. Some projects
need to run on some nodes, and in this process, we need to configure slaves. Jenkins slaves connect to the
Jenkins master using the Java Network Launch Protocol.
• The Jenkins master acts to schedule the jobs and assign slaves and send builds to slaves to execute the jobs.
• It will also monitor the slave state (offline or online) and getting back the build result responses from slaves
and the display build results on the console output. The workload of building jobs is delegated to multiple
slaves.
Jenkins
(Master)
• Go to dashboard
More Jobs
• Similarly prepare 2 more jobs.
• Notice that executing only first job Buildjob1 will trigger the other two jobs TestJob1 and DeployJob1 automatically
one after other on their completion.
Verify Delivery Pipeline View
• Go to dashboard. Click on DeliveryPipeline1 tab.
Add More Features to Pipeline View
• Go to Dashboard. Click
DeliveryPipeline1 view. Click on
Edit View.
• Projects must contain a file named Jenkinsfile in the repository root, which contains a "Pipeline script.“
• Presence of the Jenkinsfile in the root of a repository makes it eligible for Jenkins to automatically manage and
execute jobs based on repository branches.
pipeline {
agent any
stages {
stage('Hello') {
steps { echo 'Hello World' }
}
}
}
• Enter Git.
• OR
• It performs compilation of Source Code, Running Tests (unit tests and functional tests), Packaging the results
into JAR’s,WAR’s,etc., Upload the packages to remote repo’s (Nexus, Artifactory).
• Some popular IDEs supporting development with Maven Framework like Eclipse, IntelliJ IDEA, Jbuilder,
Spring Tool Suite etc.
Maven Installation
• To install maven on windows,
Download maven from
https://maven.apache.org/dow
nload.cgi
and extract it.
Local Central
Repository Repository
It is a directory on the computer where Maven runs. It It refers to any other type of repository, accessed by a variety
caches remote downloads and contains temporary of protocols such as file:// and https:// present on a web
build artifacts that you have not yet released. server, which is used when Maven needs to download
dependencies. Whenever dependency is required from the
remote repository, it is first downloaded to the local
repository, and then used.
Local Repository
• Default local repository is created under %USER_HOME%/.m2 directory.
• There is a way to change the location of maven local repository. Update settings.xml file located in
MAVEN_HOME/conf/settings.xml, for example: C:\apache-maven-3.8.6-bin\apache-maven-3.8.6\conf.
• There is a way to change the location of maven local repository. Update settings.xml file located in
MAVEN_HOME/conf/settings.xml, for example: C:\apache-maven-3.8.6-bin\apache-maven-3.8.6\conf.
Central Repository
• Maven central repository is located on the web. It has been created by the apache maven community itself.
• When Maven does not find any dependency in local repository, it starts searching in central repository.
• The path of central repository is: http://repo1.maven.org/maven2/. It requires internet access to be searched.
• Sometimes, Maven does not find a mentioned dependency in central repository as well. It then stops the build
process and output error message to console. To prevent such situation, Maven provides concept of Remote
Repository, which is developer's own custom repository containing required libraries or other project jars.
• For example, using below mentioned POM.xml, Maven will download dependency (not available in central
repository) from Remote Repositories mentioned in the same pom.xml.
<repositories>
<repository>
<id>companyname.lib1</id>
<url>http://download.companyname.org/maven2/lib1</url>
</repository>
<repository>
</repositories>
Maven Build Life Cycle
Compile
• Compile the source code of the project.
Test-compile
• Compile the test source code into the test destination directory.
Test
• Run tests using a suitable unit testing framework (Junit is one).
Package
• Take the compiled code and package it in its distributable format, such as a JAR, WAR, or EAR file.
Integration-test
• Process and deploy the package, if necessary, into an environment where integration tests can be run.
Verify
• Run any check-ups to verify the package is valid and meets quality criteria.
Install
• Install the package into the local repository, which can be used as a dependency in other projects locally.
Deploy
• Copies the final package to the remote repository for sharing with other developers and projects.
Maven Project Structure
• Maven uses a convention for project folder structure. If we follow that, we need not describe in our configuration
setting, what is located where. Maven knows from where to pick the source files, test cases etc. Following is a
snapshot from a Maven project, and it shows the project structure,
• rootproj.
├── pom.xml
└── src
├── main
│ └── java
│ └── com
│ └── ecom
│ └── App.java
└── test
└── java
└── com
└── ecom
└── AppTest.java
9 directories, 3 files
Class 14
Maven Project Object Model overview
• To configure the Maven, you need to use Project Object Model, which is stored in a pom.xml-file
• POM stands for Project Object Model. It is fundamental unit of work in Maven. It is an XML file that resides in the
base directory of the project as pom.xml.And has all the configuration settings for the project build.
• Generally we define the project dependencies (Ex: dependent jar files for a project), maven plugins to execute and
project description /version etc.
POM File Elements
• Simplest pom.xml should have 4 important information.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
</project>
• There is an element available for declaring dependencies in project pom.xml This is used to
define the dependencies that will be used by the project. Maven will look for these dependencies
when executing in the local maven repository. If not found, then Maven will download those
dependencies from the remote repository and store it in the local maven repository. Example
declaring junit and log4j as project dependencies,
•<dependencies>
• <dependency>
• <groupId>junit</groupId>
Maven
• <artifactId>junit</artifactId>
• <version>3.8.1</version>
• <scope>test</scope>
Dependency • </dependency>
• <dependency>
• <groupId>log4j</groupId>
• <artifactId>log4j</artifactId>
• <version>1.2.12</version>
• <scope>compile</scope>
• </dependency>
• </dependencies>
• An example for Maven plugin is ‘compiler’, it compiles the java source code. This compiler plugin has two goals
compiler:compile and compiler:testCompile.
Maven
webapp
structure,
run, deploy
SonarQube Installation
• Install sonarqube server from https://www.sonarqube.org/downloads/
• Type URL http://localhost:9000/ in the browser to launch SonarQube. Enter admin as both login and password.
Update password on first login. Let’s say sonar.
SonarQube Token
• Go to Administration Security Users
• Click on Tokens. Provide project name in Name textbox and click on Generate button.
squ_988144d1edd99598ca9d0cd5b0c2c991f99a12de
SonarQube Webhook
• As Jenkins and SonarQube are running in separately,
we need to create a Webhook at SonarQube Server
so that both can communicate with each other.
• Add below details under SonarQube servers section. Add SonarQube authentication token in the Server authentication
token drop down.