DevOps Lab Manual
DevOps Lab Manual
DEPARTMENT OF CSE-
(ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING)
DevOps
LAB RECORD
Regulation: R18/JNTUH
1
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
CERTIFICATE
Year
…………………………………
Signature Signature
(Internal Examiner) (External Examiner)
2
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
DEPARTMENT OF CSE
Vision
To achieve the Autonomous & University status and spread universal education by inculcating
discipline, character and knowledge into the young minds and mould them into
enlightened citizens.
Mission
To impart high quality education, in a conductive ambience, as comprehensive as
possible, with the support of all the modern technologies and make the students acquire
the ability and passion to work wisely, creatively and effectively for the betterment of
oursociety.
VISION AND MISSION OF CSE DEPARTMENT
Vision
Serving the high quality educational needs of local and rural students within the core
areas of Computer Science and Engineering and Information Technology through a
rigorous curriculum of theory, research and collaboration with other disciplines that is
distinguished by its impact on academia, industry and society.
Mission
The Mission of the department of Computer Science and Engineering is to work closely
with industry and research organizations to provide high quality computer education in
both the theoretical and applications of Computer Science and Engineering. The department
promotes original thinking, fosters research anddevelopment, evolve innovative
applications oftechnology.
3
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
DEPARTMENT OF CSE
The Graduates of Computer Science and Engineering will have successful career in technology or
managerial functions.
The Graduates of the program will have solid technical and professional foundation to continue higher
studies
The Graduates of the program will have skills to develop products, offer services and create new
knowledge.
The graduates of the program will have fundamental awareness of industry processes, tools and technologies.
4
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
PO3 Design/development of solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
considerations.
PO4 Conduct investigations of complex problems: Use research-based knowledge and research
methods including design of experiments, analysis and interpretation of data, and synthesis of
the information to provide valid conclusions.
PO5 Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities
with an understanding of the limitations.
PO6 The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to
the professional engineering practice.
PO7 Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and need
for sustainable development.
PO8 Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
PO9 Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.
PO10 Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and write
effective reports and design documentation, make effective presentations, and give and receive
clear instructions.
PO11 Project management and finance: Demonstrate knowledge and understanding of the engineering
and management principles and apply these to one’s own work, as a member and leader in a
team, to manage projects and in multidisciplinary environments.
PO12 Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
5
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
Use the foundations of science, math, and engineering together with the concepts of AI and
ML to tackle challenging computer science and engineering challenges.
PSO2 AI and ML Solution Design:
Using cutting-edge engineering and IT techniques, create creative solutions to challenging
engineering challenges involving artificial intelligence and machine learning. Take into account
ethical, sociological, and environmental aspects.
PSO3 AI and ML Research and Development:
To develop and implement cutting-edge artificial intelligence and machine learning solutions that
advance the field and meet societal needs, conduct research-based investigations that include
experiment design, data analysis, and information synthesis.
6
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
DEPARTMENT OF CSE
PREREQUISITES:
COURSE OBJECTIVES:
To unify software development (Dev) and IT operations (Ops), enhancing collaboration and efficiency
across the entire development process.
To develop a sustainable infrastructure for specific application and ensure high scalability.
COURSE OUTCOME:
Amplified effectiveness through Automation.and enhancing the quality of products and services.
DEPARTMENT OF CSE
8
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
EXPERIMENT NO-1: Write code for a simple user registration form for an event.
AIM: Write code for a simple user registration form for an event.
1. <Html>
2. <head>
3. <title>
4. Registration Page
5. </title>
6. </head>
7. <body bgcolor="Lightskyblue">
8. <br>
9. <br>
10. <form>
11.
12. <label> Firstname </label>
13. <input type="text" name="firstname" size="15"/> <br> <br>
14. <label> Middlename: </label>
15. <input type="text" name="middlename" size="15"/> <br> <br>
16. <label> Lastname: </label>
17. <input type="text" name="lastname" size="15"/> <br> <br>
18.
19. <label>Course :</label>
20. <select>
21. <option value="Course">Course</option>
22. <option value="BCA">BCA</option>
23. <option value="BBA">BBA</option>
24. <option value="B.Tech">B.Tech</option>
25. <option value="MBA">MBA</option>
26. <option value="MCA">MCA</option>
27. <option value="M.Tech">M.Tech</option>
9
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
28. </select>
29.
30. <br>
31. <br>
32. <label>
33. Gender :
34. </label><br>
35. <input type="radio" name="male"/> Male <br>
36. <input type="radio" name="female"/> Female <br>
37. <input type="radio" name="other"/> Other
38. <br>
39. <br>
40. <label>
41. Phone :
42. </label>
43. <input type="text" name="country code" value="+91" size="2"/>
44. <input type="text" name="phone" size="10"/> <br> <br>
45. Address
46. <br>
47. <textarea cols="80" rows="5" value="address">
48. </textarea>
49. <br> <br>
50. Email:
51. <input type="email" id="email" name="email"/> <br>
52. <br> <br>
53. Password:
54. <input type="Password" id="pass" name="pass"> <br>
55. <br> <br>
56. Re-type password:
57. <input type="Password" id="repass" name="repass"> <br> <br>
58. <input type="button" value="Submit"/>
59. </form>
60. </body>
61. </html>
10
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
OUTPUT:
11
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
It is used for:
Git Install:
You can download Git for free from the following website: https://www.git-scm.com/
To start using Git, we are first going to open up our Command shell.
For Windows, you can use Git bash, which comes included in Git for Windows.
For Mac and Linux you can use the built-in terminal.
Configure Git:
Now let Git know who you are. This is important for version control
systems, as each Git commit uses this information:
Example
Change the user name and e-mail address to your own. You will probably
also want to use this when registering to GitHub later on.
Now that we are in the correct directory. We can start by initializing Git!
Note: If you already have a folder/directory you would like to use for Git:
Initialize Git:
Once you have navigated to the correct folder, you can initialize Git on
that folder:
Note: Git now knows that it should watch the folder you initiated it on.
12
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
You just created your first local Git repo. But it is empty.
So let's add some files, or create a new file using your favourite text editor. Then
save or move it to the folder you just created.
If you want to learn how to create a new file using a text editor, you can visit our
HTML tutorial:
HTML Editors
For this example, I am going to use a simple HTML file like this:
Let's go back to the terminal and list the files in our current working
directory:
ls will list the files in the directory. We can see that index.html is there.
Then we check the Git status and see if it is a part of our repo:
13
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
Now Git is aware of the file, but has not added it to our repository!
Tracked - files that Git knows about and are added to the repository
Untracked - files that are in your working directory, but not added
to the repository
When you first add files to an empty repository, they are all untracked.
To get Git to track them, you need to stage them, or add them to the
staging environment.
As you are working, you may be adding, editing and removing files. But
whenever you hit a milestone or finish a part of the work, you should add
the files to a Staging Environment.
Staged files are files that are ready to be committed to the repository
you are working on. You will learn more about commit shortly.
For now, we are done working with index.html. So we can add it to the
Staging Environment:
14
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
Git Commit:
Adding commits keep track of our progress and changes as we work. Git considers
each commit change point or "save point". It is a point in the project you can go back to if
you find a bug, or want to make a change.
By adding clear messages to each commit, it is easy for yourself (and others) to see what
has changed and when.
The commit command performs a commit, and the -m "message" adds a message.
The Staging Environment has been committed to our repo, with the message:
"First release of Hello World!"
15
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
git clone <remote-repo-address>: copy the entire repository from a remote server to
remote directory. You can also use it to copy local repositories.
git config use to set user-specific configurations like email, username, and file
format.
git status shows the list of changed files or files that have yet to be staged and
committed.
git push <remote-name> <branch-name>: send local commits to remote branch of
repository.
git checkout -b <branch-name>: creates a new branch and switches to a new
branch.
git remote –v: view all remote repositories.
git remote add <remote-name> <host-or-remoteURL>: add remote server to local
repository.
git branch –d <branch-name>: delete the branch.
git pull merge commits to a local directory from a remote repository.
git merge <branch-name>: after resolving merge conflicts the command blends
selected branch into the current branch.
git log show a detailed list of commits for the current branch.
16
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
DESCRIPTION:
To practice source code management on GitHub, you can follow these steps:
These steps demonstrate how to use GitHub for source code management.
17
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
DESCRIPTION:
18
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
Once Jenkins is installed, explore it. Open the web browser and type
"localhost:8080".
Enter the credentials and log in. If you install Jenkins for the first time, the
dashboard will ask you to install the recommended plugins. Install all the
recommended plugins.
Select a new item (Name - Jenkins_demo). Choose a freestyle project and click
Ok.
Under the General tab, give a description like "This is my first Jenkins job."
Under the "Build Triggers" tab, select add built step and then click on the
"Execute Windows" batch command.
In the command box, type the following: echo "Hello... This is my first Jenkins
Demo: %date%: %time% ". Click on apply and then save.
Select build now. You can see a building history has been created. Click on that.
In the console output, you can see the output of the first Jenkins job with time
and date.
Congratulations, you've just installed Jenkins on your Windows system!
19
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
DESCRIPTION:
Create a simple Java application that you want to integrate with Jenkins.
The application should have some basic functionality, such as printing
“Hello World” or performing simple calculations.
Commit the code to a Git repository:
Create a Git repository for the application and commit the code to the
repository.
Make sure that the Git repository is accessible from the Jenkins server.
Create a Jenkins job:
20
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
Deploy the application:
If the build is successful, configure the Jenkins job to deploy the application
to a production environment.
The deployment could be as simple as copying the jar file to a production
server or using a more sophisticated deployment process, such as using a
containerization technology like Docker.
Repeat the process:
This is a basic example of how you can use Jenkins to demonstrate CI/CD in
Software development. In a real-world scenario, you would likely have more
complex requirements, such as multiple environments, different types of tests, and
a more sophisticated deployment process. However, this example should give you
a good starting point for using Jenkins for CI/CD in your software development
projects.
21
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
Here are some commonly used Docker commands for content management:
1. docker search
We can use the command docker search to search for public images on the Docker
hub. It will return information about the image name, description, stars, official and
automated.
2. docker pull
Now that we know the name of the image, we can pull that from the Docker hub
using the command docker pull. Here, we are setting the platform option as well.
22
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
Tags are used to identify images inside a repository. If we don’t specify a tag
Docker engine uses the :latest tag by default. So, in the previous example, Docker
pulled the mysql:latest image.
Since we can have multiple images under one repository, we can pull all the images
using the --all-tags option. The following command will pull all the images from
the mysql repository.
Brilliant, now we should have some images in our local machine, and to confirm,
let’s run the following command to list all the local images.
docker images
23
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
4. docker run
Alright, now that we have some images, we can try to create a container. Here we
used the --env option to set a mandatory environment variable and --detach option
to run the container in the background.
Moreover, we can use the --name option to assign a name to the container. Docker
will randomly assign a name if we don’t provide one.
5. docker ps
We can list all the running containers by using the following command.
docker ps
How about listing all the containers, including the stopped ones? We can do that by
adding --all option.
docker ps --all
24
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
6. docker stop
To stop a container, use the docker stop command with either the container id or
container name. We may stop a container if we want to change our docker run
command.
7. docker restart
Let’s restart our stopped contained by using the following command. We may want
to use this after we reboot our machine.
8. docker rename
25
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
9. docker exec
Access the running container test_db by running the following command. It’s
helpful if we want to access the MySQL command line and execute MySQL
queries.
The -i and -t options are used to access the container in an interactive mode. Then
we provide the name of the container we want to access, which in this case test_db.
Finally, the bash command is used to get a bash shell inside the container.
This command is helpful for debugging our Docker containers. It will fetch logs
from a specified container.
If we want to continue to stream new output, we can use the option -follow.
26
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
11. docker rm
docker rm test_db
Error response from daemon: You cannot remove a running container ……… Stop
the container before attempting removal or force remove
As it recommends, we can stop the container first and then remove it or use the
option -f to remove a running container forcefully.
Finally, if we want to free some disk space, we can use the docker rmi command
with the image id to remove an image.
These commands come with plenty of helpful options. If you want to know about
other available options, run the docker command_name --help command. For
example:
27
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
Choose an application:
FROM python:3.
WORKDIR /app/
28
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
Build the Docker image: Run the following command to build the Docker
image: $ docker build -t myimage. This command builds a new Docker
image using the Dockerfile and tags the image with the name “myimage”.
Run the Docker container: Run the following command to start a new
container based on the image: $ docker run –name mycontainer myimage
This command starts a new container named “mycontainer” based on the
“myimage” image and runs the Python script inside the container.
Verify the output: Run the following command to verify the output of the
container: $ docker logs mycontainer This command displays the logs of the
container and should show the “Hello World” output.
29
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
Use Docker to build a Docker image of your application. You can use a Docker
file to specify the base image, copy the application into the container, and specify
the command to run the application.
Containers.
30
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
DESCRIPTION: To install and explore Selenium for automated testing, you can
follow these steps:
32
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
PROGRAM:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
count += 1;
output = count;
}
</script>
</body>
</html>
33
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
EXPERIMENT NO-12: Develop test cases for the above containerized application
using Selenium.
AIM: To develop test cases for the above containerized application using Selenium.
System(“webdriver.chrome”, “path/to/chromedriver”);
driver = new ChromeDriver(); }
@Test public void testIncrementButton()
{
driver(“file:”);
driver(By(“increment-button”)).click();
String result = driver(By(“output”)).getText();
assert result(“1”);
}
34