DevOps Lab Manual
DevOps Lab Manual
The term ‘DevOps’ was coined in the year 2009 by Partick Debois. As its name
implies it is a conjunction of two different words, ‘Development’ and ‘Operations’.
The reason behind this name is that it combines these two areas of an
organization. Unlike the conventional organizations where these two areas were
considered separate, DevOps believes in bridging this gap by incorporating their
operations with one another at each step. By means of combining, DevOps helps
achieve agility, quality, and consistency at the same time.
In the early year of software development when it was just coming up, waterfall model was
used. Waterfall model is a very standard model used in many different fields, not just software
development. It was very useful when the requirements were concrete and the development cycles were
long. New Methodologies like Agile, Spiral Model, Extreme Programming, Feature Driven Development,
Lean Methodology have come into existence.
Definition of DevOps:
DevOps is a collaborative way of developing and deploying software. DevOps is a software
development technique that combines development (Dev) and operations (Ops) to optimize software
production and deployment efficiency, speed, and security. It aims to shorten the systems development
life cycle and provide continuous delivery with high software quality. It was designed to create a more
agile software delivery process that facilitates faster and more reliable application value in the market.
There are several practices in DevOps, which include automation, collaborative systems, fast feedback, and
continuous improvement. This concept borrows from Agile methodologies, where applications were built
and iteratively shipped at much quicker rates.
Features:
• DevOps is an approach based on agile and lean principles in which business
owners, development, operations, and quality assurance team collaborate to deliver
software in a continuous stable manner
• DevOps is an environment that promotes cross practicality, shared business tasks
and belief
• DevOps is a movement that improves IT service delivery agility
• DevOps is a culture that promotes better working relationship within the company
• DevOps is a set of practices that provides rapid, reliable software delivery
DevOps Phases:
Continuous Development
Continuous Testing
Continuous Integration
Page | 1
Continuous Deployment
Continuous Monitoring
Page | 2
EXPERIMENT NO. 1
AIM: Write code for a simple user registration
[Link]
<html>
<head>
<link href="[Link]" rel="stylesheet" />
</head>
<body>
<h1> DevOps Lab</h1>
<tr>
<td>Name</td><td><input type="text"></td>
</tr>
<tr>
<td>Contact Number</td>
<td><input type="text"></td>
</tr>
<tr>
<td>Gender</td>
<td><input type="radio" name="g">Male
<input type="radio" name="g">Female</td>
</tr>
<tr>
<td>Address</td>
<td><textarea rows="5" cols="15"></textarea></td>
</tr>
<tr>
<td>Hobbies</td>
<td><input type="checkbox">Singing
<input type="checkbox">Travelling
<input type="checkbox">Reading novels
</td>
</tr>
<tr>
<td>Skillset</td>
<td><input type="checkbox">C
<input type="checkbox">Python
<input type="checkbox">Java
</td>
</tr>
<tr>
<td>Highest Qualification</td>
Page | 3
<td><select>
<option><--SELECT--></option>
<option>Ph.D</option>
<option>M.E/[Link]</option>
<option>B.E/[Link]</option>
<option>Diploma</option>
<option>Inter</option>
<option>SSC</option>
</select>
</td>
</tr>
<td>District</td>
<td><select>
<option>--SELECT--></option>
<option>Adilabad</option>
<option>Zaheerabad</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit" value="Register"></td>
<td><input type="reset" value="Clear"></td>
</tr>
</table>
</body>
</html>
[Link]
h1{
color:green;
text-align:center;
}
h2{
color:blue;
text-align:center;
}
p{
color:red;
}
table{
background-color: cyan;
}
td{
color:red;
font-size:24px;
}
input
{
color:blue;
font-size:24px;
text-align : center;
}
select
Page | 4
{
color:blue;
font-size:24px;
text-align : center;
}
Output:
Page | 5
Page | 6
EXPERIMENT NO. 2
AIM: Explore Git and GitHub
commands. Overview of
Version Control Systems:
These days when software is developed, It is not developed with the mind-set
that there will only be one piece of code that will be deployed and that’s it.
Smaller snippets of code are deployed in regular successions with regular
feedbacks. This leads to many different versions of the code. And that creates a
need to organise the code and all of its different version of it. This is where need
for Version Control comes in. It is a practice of managing and storing different
version of a source code especially with larger companies that have multiple
projects and multiple teams working within it.
Version control systems are tools used in software development to manage changes
to source
code, documents, computer programs etc over time. They track modifications to
files, allowing teams to collaborate efficiently and maintain a history of project
changes.
Introduction to Git
Page | 8
Git Lifecycle
Working Directory
o The place where your project resides in your local disk
o This project may or may not be tracked by git
o In either case, the directory is called the working directory
o The project can be tracked by git, by using the command git init
o By doing git init, it automatically creates a hidden .git folder
Staging Area
o Once we are in the working directory, we have to specify which
files are to be tracked by git
o We do not specify all files to be tracked in git, because some
files could be temporary data which is being generated while
execution
o To add files in the staging area, we use the command git add
Commit
o Once the files are selected and are ready in the staging area, they
can now be saved in repository
o Saving a file in the repository of git is known as doing a commit
o When we commit a repository in git, the commit is identified by a commit
id
o The command forinitializing this processis git commit –m “message”
Once the files are committed, they can be pushed to a remote repository
such as GitHub
git pull
Page | 9
Program: GIT COMMANDS
Git Installation :
Git Configuration:
When starting out with a new repository, you only need to do it once; either locally,
then push to GitHub, or by cloning an existing repository.
$git init
initialize an existing directory as a Git repository
$git clone [url]
retrieve an entire repository from a hosted location via URL
$git status
show modified files in working directory, staged for your next commit
$git add [file]
add a file as it looks now to your next commit (stage)
$git reset [file]
unstage a file while retaining the changes in working directory
$git diff
diff of what is changed but not staged
$git diff --staged
diff of what is staged but not yet committed
$git commit -m “*descriptive message+”
commit your staged content as a new commit snapshot
Page |
10
Branch & Merge
$git branch
list your branches. a * will appear next to the currently active branch
$git branch [branch-name]
create a new branch at the current commit
$git checkout
switch to another branch and check it out into your working directory
$git merge [branch]
merge the specified branch’s history into the current one
$git log
show all commits in the current branch’s history
Introduction to GitHub:
Page |
12
same project, propose changes, review code, and discuss issues within the context of the
project.
● Pull Requests: Pull requests (PRs) are proposals for changes to a repository.
They allow developers to submit their changes for review, discuss the changes,
and collaboratively improve the code before merging it into the main codebase.
● Issues and Projects: GitHub allows users to track and manage project-
related issues, enhancements, and bugs. Projects and boards help organize
tasks, track progress, and manage workflows.
● Forks and Clones: Developers can create copies (forks) of repositories to
work on their own versions of a project. Cloning a repository allows developers
to create a local copy of the project on their machine.
● Branching and Merging: GitHub supports branching, where developers
can create separate lines of development for features or bug fixes. Changes
made in branches can be merged back into the main codebase.
● Actions and Workflows: GitHub Actions enable developers to automate
workflows, such as building, testing, and deploying applications, based on
triggers like code pushes or pull requests.
● GitHub Pages: This feature allows users to publish web content directly
from a GitHub repository, making it easy to create websites and documentation
for projects.
Page |
14
Stage the changes for commit:
$ git add [Link]
Commit the changes with a descriptive message
$ git commit -m "Add content to [Link]"
Create a new branch named "feature"
$ git branch feature
Switch to the "feature" branch:
$ git checkout feature
Page |
15
Program: GitHub Commands for Pushing the data from local repository to
remote github repository
Step 4: Create new file, see status, put in staging area & commit into local repo
$ touch [Link]
$ vi [Link] (put some content)
$ git status
$ git add .
$ git commit -m "1st commit file added"
$ git log
$ git show <commit-id>
$ git status
$ git branch -M main
$ git push -u origin main
Step 5: Go to remote repository and check whether project is uploaded on github.
Page |
16
Page |
17
EXPERIMENT NO. 3
AIM: Practice Source code management on GitHub. Experiment with the
source code written in program 1.
Program:
To practice source code management on GitHub, you can follow these steps:
These steps demonstrate how to use GitHub for source code management. You can
use the same steps to manage any source code projects on GitHub. Additionally,
you can also explore GitHub features such as pull requests, code review, and
branch management to enhance your source code management workflow.
$ mkdir studregistration
$ cd studregistration
$ git init
Step 2: Create new repository in your GitHub account and copy URL
Page |
18
$ git config --list
Step 4: Create new files and add the source code written in exercise 1.
$ vi [Link]
$ vi [Link]
Step 7: Create a new Branch to main and make changes to file and merge
the file.
$ git checkout –b branch1 //creates new branch
$ git branch // check the branch
$ vi [Link] //make changes to the content of the file
$ git add . // add file to git
$ git commit –m “made changes in text file on branch1”
$ git status
$ git push –u origin branch1
$ git status
$ git diff main // compares main branch and branch1
$ git merge main // merge main branch and branch1
$ git pull origin main
$ git log
Page |
19
Page |
20
EXPERIMENT NO. 4
Introduction to Jenkins:
Download the Jenkins package for your operating system from the Jenkins website.
Follow the installation instructions for your operating system to install Jenkins.
Start the Jenkins service:
o On Windows, use the Windows Services Manager to start the
Jenkinsservice.
o On Linux, use the following command to start the Jenkins service:
o sudo service jenkins startAccess the Jenkins web interface:
Open a web browser and navigate to [Link] to access the Jenkins
web interface.
If the Jenkins service is running, you will see the Jenkins login page.
Page |
21
Step 2: Initialize the Jenkins environment:
Page |
22
Follow the instructions on the Jenkins setup wizard to initialize the Jenkins
environment.
This process involves installing recommended plugins, setting up security,
and creating the first admin user.
Once the Jenkins environment is set up, you can explore the
various features and functionalities available in the web interface.
Jenkins has a rich user interface that provides access to features
such as build history, build statistics, and system information.
These are the basic steps to install and set up Jenkins. Depending on your use
case, you may need to customize your Jenkins environment further. For
example, you may need to configure build agents, set up build pipelines, or
integrate with other tools. However, these steps should give you a good
starting point for using Jenkins for CI/CD in your software development
projects.
Copy the path of passcode and open the terminal, and in terminal type
$ sudo cat <path of passcode>
Copy the password and paste in browser to continue installation. Skip user creation,
and after login, in user plug-ins set & update the admin password to “admin”
Page |
23
Page |
24
EXPERIMENT NO. 5
CI/CD Principles:
Page |
25
Automation: CD pipelines automate the deployment process, reducing
therisk of human error and ensuring consistent deployments.
Deployment to Staging: Code changes are deployed first to a staging
environment where
Page |
26
further testing and validation occur.
Deployment to Production: After passing all tests in the staging
environment, code changes are automatically deployed to the production
environment, often with zero downtime.
Rollbacks: In case of issues, CD pipelines provide the ability to rollback
to a previous version quickly.
Page |
27
Program #1 : Create a Jenkins Job for executing shell
commands
Steps:
In browser open [Link] and login in using your account.
Create a new Jenkins job using the "Freestyle project" type.
o In the dash board, Click on New item to create job.
o Assign a meaningful name for the job and select free style project
option and click on OK button.
Provide a description about application and under Buildsteps option choose
execute shell.
Type few linux commands in shell window.
o whoami
o pwd
o mkdir demo
o ls
o cd demo
o echo “Hello Jenkins” > [Link]
o ls
o cat [Link]
Cilck on Save button.
Click on build now option available in dash board.
To watch the output click on Console output
Steps:
Create a file [Link] and type the code for reverse of a number
and save file
class ReverseNumber
{
public static void main(String args[])
{
int
n=[Link](args[
0]); int rev=0;
int r;
while(n>0)
{
r=n%10;
rev=(rev*10)+
r; n=n/10;
}
[Link]("Reverse number:"+rev);
}
}
Page |
28
In browser open [Link] and login in using your account.
Create a new Jenkins job using the "Freestyle project" type.
o In the dash board, Click on New item to create job.
Page |
29
o Assign a meaningful name for the job and select free style project
option and click on OK button.
Provide a description about application and under Buildsteps option choose
execute shell.
Copy the program into the Jenkins evnvironment workspace.
Type commands for execution of your java program.
o javac [Link]
o java ReverseNumber 1234
Cilck on Save button.
Click on build now option available in dash board.
To watch the output click on Console output
Steps:
Create a file [Link] and type the code for creating pyramid
pattern and save file
class PatternDemo
{
public static void main(String args[])
{
int
n=[Link](args[
0]); for(int i=1;i<=n;i+
+)
{
for(int j=1;j<=i;j++)
{
[Link](i+"\t");
}
[Link]();
}
}
}
Page |
31
Cilck on Save button.
Click on build now option available in dash board and it will prompt you to enter
value for n1.
Enter value for parameter and click ok.
To watch the output click on Console output
Steps:
Create a file [Link] and type the code for Biggest of three numbers and
save file
class Biggest
{
public static void main(String args[])
{
int
n1=[Link](args
[0]); int
n2=[Link](args
[1]); int
n3=[Link](args[
2]);
if((n1>n2)&&(n1>n3))
{
[Link](n1+" is biggest");
}
else if((n2>n1)&&(n2>n3))
{
[Link](n2+" is biggest");
}
else
{[Link](n3+" is biggest");
}
}
}
Login into your GitHub Account and create a new repository with name
“Biggestnum”
Upload the file [Link] into your GitHub repository and commit the
changes.
Copy the URL of your Git Repository
In browser open [Link] and login in using your account.
Create a new Jenkins job using the "Freestyle project" type.
o In the dash board, Click on New item to create job.
Page |
32
o Assign a meaningful name for the job and select free style project
option and click on OK button.
In the job configuration, provide description about job and choose
"This project is parameterized."
Add 3 "String Parameter" named “n1” , “n2” nad “n3” and set its default
values.
Under source management choose Git and provide the Git URL there.
Set Branches to build -> Branch Specifier to the working Git branch (ex */main)
Page |
33
Under Buildsteps option, choose execute shell.
Type commands for execution of your java program.
o javac [Link]
o java Biggest $n1 $n2 $n3
Cilck on Save button.
Click on build parameterized now option available in dash board and it will
prompt you to enter value for n1, n2 ad n3.
Enter values for parameter and click ok.
To watch the output click on Console output
pipeline {
agent
any
stages{
stage('compile')
{ steps{
echo "Compiled Successfully";
}
}
stage('Junit
')
{ steps{
echo "JUnit test passed Successfully";
}
}
stage('Qualityche
ck'){ steps{
echo " Quality Check passed Successfully";
}
}
stage('Deploy'){
steps{
echo "Deployed Successfully";
}
}
post{
Page |
34
always{
Page |
35
echo "This will always run"
}
success{
echo "This will run on success"
}
failure{
echo "This will run on failure"
}
unstable{
echo "This will run only if the run is marked as Unstable"
}
changed{
echo "Pipe line changed"
}
}
}
Page |
36
Page |
37
EXPERIMENT NO. 6
Benefits of Containerization:
Page |
39
Containerization vs. Virtualization:
Docker
Docker is a tool that helps in developing, building, deploying and executing software in
isolation. It does so by creating containers that completely wrap software. Docker is
a containerization technology that is widely used for managing application
containers. Docker is Simple, Fast, has Easy Collaboration,
Built for Developers by Developers and has large Docker Community.
Docker Environment
Docker Engine
o Docker engine is as the name suggests, it’s a technology
that allows for the creation and management of all the
Docker Processes. It has three major parts to it.
Docker CLI
Docker API
Docker Daemon
Page |
40
Docker Objects
o When you use Docker, you are creating and using docker objects like
Page |
41
Docker Images: Docker images are sets of instructions that are
used to create containers and execute code inside it.
Docker Containers : Wraps code and all its dependencies, libraries,
OS into a single deployable unit
Docker Volumes: Storage structure- three types are
Volume – storage managed by docker
Bind mount – external storage not managed by Docker
Tmpfs mount – store data for temporary use and throw.
Docker Networks:provides connection between one or more
containers
Bridge Network (between 2 containers)
Host Network (container and external host)
Overlay Network (many to many)
None Network ( no network – single container)
Docker Swarm Nodes & Services
Docker Registry (Docker Hub)
Docker Compose – Service that lets us launch multiple containers at the same
time.
Docker Swarm - an orchestration management tool that runs on Docker
applications. It helps end-users in creating and deploying a cluster of
Docker nodes. Each node of a Docker Swarm is a Docker daemon, and all
Docker daemons interact using the Docker API.
Docker Architecture
Docker architecture consists of Docker client, Docker Daemon running on Docker Host and
DockerHub repository.
Page |
42
Main Components of Docker
Page |
43
Dockerization of a Application
Push
Run
Page |
45
Remove unused images, containers, and networks
$ docker system prune
Container Management
Commands List the running
containers.
$ docker ps
List all the containers, both running and stopped.
$ docker ps -a
Lists all images stored locally on the host
$ docker images
Run a command in a container based on an image.
$ docker run [image]
[command] Create, start, and name a
container.
$ docker run –name [container-name]
[image] Map a host port to a container port.
$ docker run -p [host]: [container-
port] [image] Run a container and remove it
after it stops.
$ docker run --rm [image]
Run a detached (background) container.
$ docker run -d [image]
Run an interactive process, e.g., a shell, in a container.
$ docker run -it [image]
Run a shell inside a running container.
$ docker exec –it [container]
[shell] Create a container without
starting it.
$ docker create [image]
Create an interactive container with pseudo-TTY.
$ docker create –it [image]
Docker start: Start one or more stopped containers.
$ docker start [mycontainer]
Docker stop: Stop one or more running containers.
Page |
46
$ docker stop
[mycontainer] Stop a container
and start it again.
Page |
47
$ docker restart
[container] Pause processes in a
running container.
$ docker pause [container]
Unpause processes in a running
container.
$ docker unpause
[container] Block input until the
container stops.
$ docker wait [container]
Send a SIGKILL signal to stop a container.
$ docker kill [container]
Attach local standard input, output and error.
$ docker attach
[container] Rename a
container.
$ docker rename [container] [new-
name] Remove a stopped container.
$ docker rm [container]
Force remove a container, even if it is running.
$ docker rm -f
[container] View logs for a
running container.
$ docker logs [container]
Copy a local file to a directory in a container
$ docker cp [file-path] CONTAINER:
[path] Update the configuration of a
container.
$ docker update
[container] Show port mapping
for a container.
$ docker port
[container] Show running
processes in a container.
Page |
48
$ docker top [container]
Show live resource usage statistics for a container.
$ docker stats [container]
Show changes to files or directories on the filesystem.
$ docker diff [container]
Page |
49
Image Management Commands
Create an image from a Dockerfile.
$ docker build [dockerfile-path]
Build an image using the files from the current path.
$ docker build .
Create an image from a Dockerfile and tag it.
$ docker build -t [name]:[tag]
[location] Specify a file to build from.
$ docker build -f
[file] Pull an image from a
registry.
$ docker pull
[image] Push an image to
a registry.
$ docker push
[image] Create an image
from a tarball.
$ docker import [url/file]
Create an image from a
container.
$ docker commit [container] [new-
image] Tag an image.
$ docker tag [image] [image]:
[tag] Show all locally stored top
level images.
$ docker
images Show history
for an image.
$ docker history
[image] Remove an
image.
$ docker rmi [image]
Load an image from a tar archive file.
$ docker load –image [tar-file]
Page |
50
Network Management Commands
Save an image to a tar archive file.
$ docker save [image] > [tar-
file] Search Docker Hub for images.
Page |
51
$ docker search
[query] Remove unused
images
$ docker image
prune View available
networks.
$ docker network ls
Remove a network.
$ docker network rm
[network] Show information about
a network.
$ docker network inspect
[network] Connect a container to a
network.
$ docker network connect [network]
[container] Disconnect a container from a network.
$ docker network disconnect [network] [container]
Page |
52
Programs:
// runs ubuntu image in container named MyContainerA and opens shell script
Page |
53
Program #3: Run an Mongo image in Docker container
named “mongoCon” and execute some mongodb
commands
// runs mongo image in container named mongoCon and opens mongo command prompt
Page |
54
Page |
55
EXPERIMENT NO. 7
<html>
<head>
<title> Hello Page</title>
</head>
<body>
<<h1> Welcome to HTML Docker </h1>
</body>
</html>
o vi Dockerfile
FROM nginx:latest
WORKDIR
/usr/share/nginx/html
COPY ./[Link] .
EXPOSE 80
o $ docker push
Dockerhubusername/imagename Eg:
$ docker push
ascheryakathi/htmlimage
Page |
57
Program # 2: JAVA docker image
Steps to create JAVA docker image
Login to super user using sudo su command
o $ sudo su
Create a directory JavaDemo and create a JAVA file and Docker file inside it.
o $ mkdir JavaDemo
o $ cd JavaDemo
o vi [Link]
class Hello
{
public static void main(String args[])
{
[Link]("Hello Docker from java");
}
}
o vi Dockerfile
FROM openjdk:11
WORKDIR /app
COPY
./[Link] .
RUN javac
[Link]
CMD ["java", "Hello"]
o $ docker push
Dockerhubusername/imagename Eg:
$ docker push
ascheryakathi/javaimage
o vi Dockerfile
o $ docker push
Dockerhubusername/imagename Eg: $
docker push
ascheryakathi/pythonimage
Page |
59
Program # 4: Node docker image
Steps to create Node docker image
Login to super user using sudo su command
o $ sudo su
Create a directory nodeDemo and create a Node file and Docker file inside it.
o $ mkdir nodeDemo
o $ cd nodeDemo
o vi [Link]
o vi Dockerfile
FROM
node:alpine
WORKDIR /app
COPY . /app
CMD node [Link]
o $ docker push
Dockerhubusername/imagename Eg:
$ docker push
ascheryakathi/nodeimage
Page |
60
Program # 5: Python FLASK docker image
Steps to create Python FLASK docker image
Login to super user using sudo su command
o $ sudo su
Create a directory flaskDemo and create a python file and Docker file inside
it.
o $ mkdir flaskDemo
o $ cd flaskDemo
o vi [Link]
from flask import Flask
@[Link]('/')
def run():
return "Hello, World!"
o vi [Link]
flask
o vi Dockerfile
FROM python:latest
WORKDIR /python-flask-
docker copy . /python-
flask-docker
RUN pip install -r
[Link] EXPOSE
8000
CMD python ./[Link]
Page |
62
Program # 6: Creating multiple containers in single step Using
Docker Compose
1. Busy Box : Create two instances of busybox images in two
containers named bbConA and bbConB and ping bbConB from
bbConA.
Note: BusyBox combines tiny versions of many common Unix utilities into a
single small executable. It provides most of the Unix utilities (Eg: ping)
busybox1:
image: busybox:latest
container_name: bbConA
command: sh -c 'ping
busybox2' links:
- busybox2
busybox2:
image: busybox:latest
container_name:
bbConB command:
sleep infinity
Page |
63
Program # 7: Create MYSQL image Using Docker Compose
yaml file and execute some SQL commands inside image
Create a directory mysqlDemo and create a docker compose yaml file inside
it.
o $ mkdir mysqlDemo
o $ cd mysqlDemo
o vi [Link]
version: "3.7"
services:
mysql:
image: mysql:5.7
container_name:
mysql-5.7
restart: always # always restart
environment:
MYSQL_DATABASE: 'test' # name of database
MYSQL_USER: 'sample' # sample is the name
of user MYSQL_PASSWORD: 'password' # password
for sample user MYSQL_ROOT_PASSWORD: 'password'
# password for root
user ports:
- '3306:3306' # host port 3306 is mapper to docker
port 3306 expose:
- '3306'
volumes:
- mysql-db:/var/lib/
mysql volumes:
mysql-db:
Page |
64
Execution of some SQL commands inside Docker image
o Mysql> show databases;
o Mysql> use test;
o Mysql> show tables;
o Mysql> create table student(ID int, NAME varchar(20), BRANCH
varchar(20));
o Mysql> insert into student values(1,”RAM”, “IT”);
o Mysql> insert into student values(1,”SHYAM”, “IT”);
o Mysql> insert into student values(1,”JOHN”, “CSE”);
o Mysql> select * from student;
o Mysql> exit
Page |
65
Page |
66
EXPERIMENT NO. 8
<body>
<img src="[Link]" alt="stud reg image" class="center">
<h1> DevOps Lab</h1>
<tr>
<td>Name</td><td><input type="text" name="sname"></td>
</tr>
<tr>
<td>Contact Number</td>
<td><input type="text" name="scon"></td>
</tr>
<tr>
<td>Gender</td>
<td><input type="radio" name="g">Male
<input type="radio" name="g">Female</td>
</tr>
Page |
67
<tr>
Page |
68
<td>Address</td>
<td><textarea rows="5" cols="15" name="sadd"></textarea></td>
</tr>
<tr>
<td>Hobbies</td>
<td><input type="checkbox" name="shob">Singing
<input type="checkbox" name="shob">Travelling
<input type="checkbox" name="shob">Reading novels
</td>
</tr>
<tr>
<td>Skillset</td>
<td><input type="checkbox" name="sss">C
<input type="checkbox" name="sss">Python
<input type="checkbox" name="sss">Java
</td>
</tr>
<tr>
<td>Highest Qualification</td>
<td><select name="shq">
<option><--SELECT--></option>
<option>Ph.D</option>
<option>M.E/[Link]</option>
<option>B.E/[Link]</option>
<option>Diploma</option>
<option>Inter</option>
<option>SSC</option>
</select>
</td>
</tr>
<td>District</td>
<td><select name="sdis">
<option>--SELECT--></option>
<option>Adilabad</option>
<option>Zaheerabad</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit" name="submit" value="Register"></td>
<td><input type="reset" value="Clear"></td>
</tr>
</table>
</form>
</body>
</html>
vi [Link]
h1{
color:green;
text-align:center;
Page |
69
}
h2{
color:blue;
text-align:center;
}
p{
color:red;
}
table{
background-color: cyan;
}
td{
color:red;
font-size:24px;
}
input
{
color:blue;
font-size:24px;
text-align : center;
}
select
{
color:blue;
font-size:24px;
text-align : center;
}
.center
{ display:
block;
margin-left: auto;
margin-right: auto;
width: 50%;
}
vi [Link]
[Link]([Link]('public'));
[Link]('/[Link]', function (req, res) {
[Link]( dirname + "/" + "[Link]" );
})
Page |
71
})
vi Dockerfile
FROM node:14
WORKDIR /app
COPY
package*.json .
RUN npm install
RUN npm install
express COPY . /app
EXPOSE 8081
CMD ["node", "[Link]"]
vi [Link]
version:
"3.0"
services:
myweb:
image:
node:14
build: .
container_name:
nodecons restart:
always
ports:
- "8081:8081"
expose:
- "8081"
Page |
72
o $ node [Link]
Page |
73
o $ docker build –t studregimage .
o $ docker run --rm -it -p 8081:8081 --name nodecon studregimage
o $ docker push
Dockerhubusername/imagename Eg: $
docker push
ascheryakathi/studregimage
Page |
74
Page |
75
EXPERIMENT NO. 9
Page |
76
Load Balancing: Services in Kubernetes can distribute traffic among pods,
providing high availability and distributing workloads evenly.
Self-healing: Kubernetes monitors the health of pods and can automatically restart
or replace failed
Page |
77
instances to maintain desired application availability.
Rolling Updates and Rollbacks: Kubernetes allows for controlled, rolling
updates of applications, ensuring zero-downtime deployments. If issues arise,
rollbacks can be performed with ease.
Storage Orchestration: Kubernetes provides mechanisms for attaching
storage volumes to containers, enabling data persistence and sharing.
Configuration Management: Kubernetes supports configuration management
through ConfigMaps and Secrets, making it easy to manage application
configurations.
Extensibility: Kubernetes is highly extensible, with a vast ecosystem of
plugins and extensions, including Helm charts for packaging applications and
custom resources for defining custom objects.
Minikube
For configuring minikube drivers we need Container or virtual machine manager, such
as: Docker, QEMU, Hyperkit, Hyper-V, KVM, Parallels, Podman, VirtualBox, or
VMware Fusion/Workstation
Page |
78
Program:
Installation of kubernetes
sudo su
docker version ( install docker if not available)
curl -LO
[Link]
amd64 sudo install minikube-linux-amd64 /usr/local/bin/minikube &&
rm minikube-linux-amd64 minikube version
minikube start --
driver=docker minikube
kubectl -- get po -A snap
install kubectl --classic
kubectl version
minikube start --force
minikube addons enable ingress
minikube start --nodes 2 -p multinode-
demo minikube dashboard
Kubernetes Commands:
Cluster Management
Display endpoint information about the master and services in the cluster
kubectl cluster-info
List everything
kubectl get all --all-namespaces
Namespaces
Create namespace <name>
kubectl create namespace <namespace_name>
Nodes
List one or more nodes
kubectl get node
Delete a pod
kubectl delete pod <pod_name>
Create a pod
kubectl create pod <pod_name>
Page |
80
kubectl top pod
Deployments
List one or more deployments
kubectl get deployment
Edit and update the definition of one or more deployment on the server
kubectl edit deployment <deployment_name>
Delete deployments
kubectl delete deployment <deployment_name>
ReplicaSets
List ReplicaSets
kubectl get replicasets
Scale a ReplicaSet
kubectl scale --replicas=[x]
Logs
Print the logs for a pod
kubectl logs <pod_name>
Page |
81
Print the logs for a pod and follow new logs
kubectl logs -f <pod_name>
Manifest Files
Apply a configuration to an object by filename or stdin. Overrides the existing configuration.
kubectl apply -f manifest_file.yaml
Create objects
kubectl create -f manifest_file.yaml
Delete an object
kubectl delete -f manifest_file.yaml
Secrets
Create a secret
kubectl create secret
List secrets
kubectl get secrets
Delete a secret
kubectl delete secret <secret_name>
Services
List one or more services
kubectl get services
Page |
82
Expose a replication controller, service, deployment or pod as a new Kubernetes service
kubectl expose deployment [deployment_name]
There are four types of services that Kubernetes supports: ClusterIP, NodePort, LoadBalancer, Ingress
Workflow in Kubernetes
Page |
83
Page |
84
EXPERIMENT NO. 10
Step 5: Execute the mongo deployment and run some commands in mongo
$ kubectl get pods ( copy pod id and use it in next command to run the pod)
$ kubectl exec -it mongo-depl-85shtudf -- /bin/bash
root@mongo-depl-id..# show databases;
Page |
85
# [Link]( , name : “Sunny”, age: 20, dept : “IT” - );
Page |
86
# [Link]( , name : “Sony”, age: 22, gender :
“Female”, dept : “IT” - ); # [Link]();
# [Link]( , name :
“Sunny” - ); # [Link]();
# show
collections; #
exit
$ touch [Link]
$ vi [Link]
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 2 # tells deployment to run 2 pods matching the template
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
Create a simple web application (e.g., a static HTML page) or use an existing one.
Create a directory HtmlDemo and create a HTML file and Docker file inside
it.
o $ mkdir kubernestesDemo
o $ cd kubernestesDemo
o vi [Link]
<html>
<head>
<title> Hello Page</title>
</head>
<body>
<<h1> Welcome to HTML Docker run using Kubernetes</h1>
</body>
</html>
o vi Dockerfile
FROM nginx:latest
WORKDIR
/usr/share/nginx/html
COPY ./[Link] .
EXPOSE 80
[Link]
Page |
88
apiVersion:
apps/v1 kind:
Deployment
metadata:
name: my-web-app-deployment
spec:
replicas: 3 # Number of pods to
create selector:
matchLabels:
app: my-web-app # Label to match pods
template:
metadata:
label
s: app: my-web-app # Label assigned to pods
spec:
containers:
- name: my-web-app-container
image: my-web-app:latest # Docker
image to use ports:
- containerPort: 80 # Port to expose
Page |
89
Page |
90
EXPERIMENT NO. 11
Selenium can be easily deployed on platforms such as Windows, Linux, Solaris and Macintosh.
Moreover, it supports OS (Operating System) for mobile applications like iOS, windows mobile and
android.
Selenium supports a variety of programming languages through the use of drivers specific to each
[Link] supported by Selenium include C#, Java, Perl, PHP, Python and [Link],
Selenium Web driver is most popular with Java and C#. Selenium test scripts can be coded in any of the
supported programming languages and can be run directly in most modern web browsers. Browsers
supported by Selenium include Internet Explorer, Mozilla Firefox, Google Chrome and Safari.
Selenium can be used to automate functional tests and can be integrated with automation test tools such
as Maven, Jenkins, & Docker to achieve continuous testing. It can also be integrated with tools such as
TestNG, & JUnit for managing test cases and generating reports.
One disadvantage of Selenium automation testing is that it works only for web applications, which
leaves desktop and mobile apps out in the cold.
Page |
91
Fig: Selenium suite
[Link] IDE
Shinya Kasatani developed the Selenium Integrated Development Environment (IDE) in 2006.
Conventionally, it is an easy-to-use interface that records the user interactions to build automated test
scripts. It is a Firefox or Chrome plugin, generally used as a prototyping tool. It was mainly developed
to speed up the creation of automation scripts.
IDE ceased to exist in August 2017 when Firefox upgraded to the new Firefox 55 version, which no
longer supported Selenium IDE. Applitools rewrote the old Selenium IDE and released a new version
recently. The latest version came with several advancements, such as:
Installing IDE:
Step 1- Open the Firefox browser
Step 2- Click on the menu in the top right corner
Step 3- Click on Add-ons in the drop-down box.
Step 4- Click on Find more add-ons and type “Selenium IDE”
Step 5- Click on Add to Firefox
Page |
92
[Link] WebDriver
Developed by Simon Stewart in 2006, Selenium WebDriver was the first cross-platform testing
framework that could configure and control the browsers on the OS level. It served as a programming
interface to create and run test cases.
Unlike Selenium RC, WebDriver does not require a core engine like RC and interacts natively with the
browser applications. WebDriver also supports various programming languages like Python, Ruby,
PHP, and Perl. It can also be integrated with frameworks like TestNG and JUnit for Selenium
automation testing management.
1. Download and Install Java 8 or higher version - Install the latest version of the Java development
kit.
2. Download and configure Eclipse or any Java IDE of your choice
3. Download Selenium WebDriver Java Client
1. Navigate to the official Selenium page.
2. Scroll down through the web page and locate Selenium Client and WebDriver Language
Bindings.
3. Click on the "Download" link of Java Client Driver . Unzip the file in a directory. It
consists of the Jar files required to configure Selenium WebDriver in the IDE.
4. Download the Browser driver - The automation scripts must be compatible with
any browser. Every browser supported by Selenium comes with its driver files.
5. Configure Selenium WebDriver - The final step is to configure the Selenium
WebDriver with the Eclipse IDE. In simple terms, we create a new Java project to
build our test script.
[Link] Grid
Selenium Grid was developed by Patrick Lightbody to minimize the execution time of Selenium
automation testing. Selenium Grid allows the parallel execution of tests on different browsers and
different operating systems, facilitating parallel execution. Grid is exceptionally flexible and is
integrated with other suite components for simultaneous performance.
The Grid consists of a hub connected to several nodes. It receives the test to be executed along with
information about the operating system and browser to be run on. The Grid then picks a node that
conforms to the requirements (browser and platform) and passes the test to that node. The node now
runs the browser and executes the Selenium commands within it.
Page |
93
Page |
94
EXPERIMENT NO. 12
o $ mkdir googleDemo
o $ cd googleDemo
o vi [Link]
node -v
// check whether node is installed. If not, install using below commands.
// sudo apt-get update
//sudo apt install nodejs
npm -v
// check whether npm is installed. If not, install using below commands.
//sudo apt install npm
Note: Selenium web drivers run only in Higher versions of node, so see to that node
version 16 and above are installed.
Page |
95
Program # 2: Write a JavaScript program for login
validation application and test it using Selenium.
o $ mkdir myloginDemo
o $ cd myloginDemo
o vi [Link]
<html>
<head>
<title> Login Page</title>
<script language="javascript">
function validate()
{
var u=[Link];
var p=[Link];
o vi [Link]
<html>
<head>
<title> Success </title>
Page |
96
</head>
<body>
<h1 align="center" style="color:red"> Login Succeess</h1>
</body>
</html>
o vi [Link]
<html>
<head>
<title> Fail </title>
</head>
<body>
o vi [Link]
try {
await [Link]("[Link]
await [Link]([Link]("un")).sendKeys("MVSREC");
await [Link]([Link]("pw")).sendKeys("ITD");
await [Link]([Link]("s")).click();
[Link](title,"Login Page");
[Link]("success");
} finally {
await [Link]();
}
}
loginTest();
Page |
97
Step 2: Initialize the project and execute it
node -v
// check whether node is installed. If not, install using below commands.
// sudo apt-get update
//sudo apt install nodejs
npm -v
// check whether npm is installed. If not, install using below commands.
//sudo apt install npm
o $ mkdir collegeloginDemo
o $ cd collegeloginDemo
o vi [Link]
try {
await [Link]("[Link]
await [Link]([Link]("txtUserName")).sendKeys("245121737129");
await [Link]([Link]("txtPassword")).sendKeys("245121737129");
await [Link]([Link]("btnSubmit")).click();
[Link](user, "245121737129");
[Link]("success");
Page |
98
await [Link]([Link]("Stud_cpModules_imgbtnExams")).click();
await [Link]([Link]("cpBody_lnkSem")).click();
[Link](ur,
"[Link]
node -v
// check whether node is installed. If not, install using below commands.
// sudo apt-get update
//sudo apt install nodejs
npm -v
// check whether npm is installed. If not, install using below commands.
//sudo apt install npm
Page |
99
Page |
100
EXPERIMENT NO. 13
Provide a project name and select the JRE that you wish to use. It is
advisable to use the default JRE. Select it and click on finish.
On the project name, right click and add new package (loginval)
Now, right click on package name and add new java class.(Loginval)
To do that, Right-click on Src folder>>New>>Class
Write the following code.
package loginval;
import [Link].*;
import [Link].*;
Page |
101
The next and most crucial step is to add the downloaded JAR file [Step 1].
Page |
102
To add JAR file, right-click on the Project>>Build Path>>Configure Build Path.
Select libraries and then Add External JARs.
Open the folders in which you’ve saved your JAR files and select the
executable JAR file. Click on open to add it.
Click on the libs folder>> Select the files>> Open
Once you’re done adding the library files, click on Apply and Close.
Step 5: Output
Chrome browser should open automatically and navigate to [Link] and search for the
word chrome driver and display results.
Page |
103
Page |
104
EXPERIMENT NO. 14
Program: Steps
function op(k)
{
oper=k;
prev=parseInt([Link]);
[Link]=0;
}
function mod()
{
a=parseInt([Link]);
b=[Link](a/10);
[Link]=b;
function eq()
{
curr=parseInt([Link]);
Page |
105
switch(oper)
Page |
106
{
case 1: var result=prev+curr;break;
[Link]=result;
}
</script>
<body >
<form name="f1">
<h1 align="center">Basic Calculator</h1>
<tr>
<td><input id = "4" type="button" value=" 4 " onclick="num(4)">
<td><input id = "5" type="button" value=" 5 " onclick="num(5)">
<td><input id = "6" type="button" value=" 6 " onclick="num(6)">
<td><input id = "sub" type="button" value=" - " onclick="op(2)">
</tr>
<tr>
<td><input id = "7" type="button" value=" 7 " onclick="num(7)">
<td><input id = "8" type="button" value=" 8 " onclick="num(8)" >
<td><input id = "9" type="button" value=" 9 " onclick="num(9)">
<td><input id = "mul" type="button" value=" * " onclick="op(3)">
</tr>
<tr>
<td><input id = "0" type="button" value=" 0 " onclick="num(0)">
<td><input id = "div" type="button" value=" / " onclick="op(4)">
<td><input id = "mod" type="button" value=" % " onclick="op(5)">
<td><input id = "equ" type="button" value=" = " onclick="eq()">
</tr>
<tr>
<td colspan="2"><input id = "c" type="reset" value=" c " ><td>
<input id = "bs" type="button" value=" <--- " onclick="mod()">
</tr>
</table>
</form>
</body>
</html>
vi [Link]
Page |
107
const { Builder, By , util } = require("selenium-webdriver");
try {
await [Link]("[Link]
await [Link](2000);
await [Link]([Link]("5")).click();
await [Link]([Link]("add")).click();
await [Link]([Link]("8")).click();
await [Link]([Link]("equ")).click();
await [Link](2000);
await [Link](2000);
[Link](value,'13');
await [Link]([Link]("c")).click();
await [Link]([Link]("5")).click();
await [Link]([Link]("sub")).click();
await [Link]([Link]("2")).click();
await [Link]([Link]("equ")).click();
await [Link](2000);
await [Link]([Link]("c")).click();
await [Link]([Link]("5")).click();
await [Link]([Link]("mul")).click();
await [Link]([Link]("2")).click();
await [Link]([Link]("equ")).click();
await [Link](2000);
await [Link](2000);
[Link](v2,'10');
Page |
108
[Link](" Multiplication success");
await [Link]([Link]("c")).click();
await [Link]([Link]("6")).click();
await [Link]([Link]("div")).click();
await [Link]([Link]("2")).click();
await [Link]([Link]("equ")).click();
await [Link](2000);
await [Link](2000);
[Link](v3,'3');
} finally {
await [Link]();
}
}
calciTest();
vi Dockerfile
FROM node:16.14.0
WORKDIR /app
COPY
package*.json .
RUN npm install
COPY . /app
CMD ["node" , "[Link]"]
vi [Link]
version:
"3.0"
services:
myweb:
image:
node:16.14.0
build: .
container_name:
calcicons restart:
always
ports:
- "8081:8081"
expose:
- "8081"
Page |
109
o $ apt install npm
o $ npm install -g express
o $ node –v
Page |
110
o $ npm –v
o $ npm init
o $ npm install selenium-webdriver // add selenium web driver as
dependency
o $ npm init
o $ node [Link]
[Link]
apiVersion:
apps/v1 kind:
Deployment
metadata:
name: calci-app-deployment
spec:
replicas: 1 # Number of pods to
create selector:
matchLabels:
app: calci-webapp # Label to match pods
template:
metadata:
label
s: app: calci-webapp # Label assigned to pods
spec:
containers:
- name: calci-webapp-container
image: calciimage:latest # Docker image
to use ports:
- containerPort: 80 # Port to expose
Page |
111
$ kubectl describe deployment my-web-app-deployment
o $ docker push
Dockerhubusername/imagename Eg:
$ docker push
ascheryakathi/calciimage
Page |
112
Page |
113
EXPERIMENT NO. 15
Page |
114
Page |
115
Page |
116