DevOps and Microservices Lab Report
DevOps and Microservices Lab Report
M.E. COMPUTER SCIENCE AND ENGINEERING (WITH SPECIALIZATION IN ARTIFICAIL INTELLIGENCE AND
MACHINE LEARNING)
Register Number :
BONAFIDE CERTIFICATE
[Link]
Institute Values
We develop in each member the ability and passion to work effectively for the betterment of humanity
with cultural awareness, high ethical and moral values and a sense of social responsibility
Department Vision and Mission
Department Vision
Emerge as a renewed department for globally competent Computer Science Engineers.
Department Mission
To impart quality education, problem solving and Entrepreneurship skills in Computer Science and
M1
Engineering.
M2 To facilitate research based innovative projects in Computer Science and Engineering.
M3 To develop Moral, Ethical Values and Social Responsibility among the students.
WK1 (Natural Science): A systematic, theory-based understanding of the natural sciences applicable to the
discipline and awareness of relevant social sciences.
WK2 (Mathematics and Modelling): Conceptually-based mathematics, numerical analysis, data analysis, statistics
and formal aspects of computer and information science to support detailed analysis and modelling applicable to the
discipline.
WK4 (Engineering Specialization): Engineering specialist knowledge that provides theoretical frameworks and
bodies of knowledge for the accepted practice areas in the engineering discipline; much is at the forefront of the
discipline.
WK5 (Environmental impact on design and practice): Knowledge, including efficient resource use,
environmental impacts, whole-life cost, reuse of resources, net zero carbon, and similar concepts, that supports
engineering design and operations in a practice area.
WK6 (Newer Practical Knowledge): Knowledge of engineering practice (technology) in the practice areas in the
engineering discipline.
WK7 (Engineer role and responsibility in Society): Knowledge of the role of engineering in society and
identified issues in engineering practice in the discipline, such as the professional responsibility of an engineer to
public safety and sustainable development.
Program Outcomes (PO)
PO1: Engineering Knowledge: Apply knowledge of mathematics, natural science, computing, engineering
fundamentals and an engineering specialization as specified in WK1 to WK4 respectively to develop to the
solution of complex engineering problems.
PO2: Problem Analysis: Identify, formulate, review research literature and analyze complex engineering
problems reaching substantiated conclusions with consideration for sustainable development. (WK1 to
WK4)
PO3: Design/Development of Solutions: Design creative solutions for complex engineering problems
and design/develop systems/components/processes to meet identified needs with consideration for the
public health and safety, whole-life cost, net zero carbon, culture, society and environment as required.
(WK5)
PO4: Conduct Investigations of Complex Problems: Conduct investigations of complex engineering
problems using research-based knowledge including design of experiments, modelling, analysis &
interpretation of data to provide valid conclusions. (WK8)
PO5: Engineering Tool Usage: Create, select and apply appropriate techniques, resources and
modern engineering & IT tools, including prediction and modelling recognizing their limitations to
solve complex engineering problems. (WK2 and WK6)
PO6: The Engineer and the World: Analyze and evaluate societal and environmental aspects while
solving complex engineering problems for its impact on sustainability with reference to economy,
health, safety, legal framework, culture and environment. (WK1, WK5, and WK7)
PO7: Ethics: Apply ethical principles and commit to professional ethics, human values, diversity and
inclusion; adhere to national & international laws. (WK9)
PO8: Individual and Collaborative Team work: Function effectively as an individual, and as a
member or leader in diverse/multi-disciplinary teams.
PO9: Communication: Communicate effectively and inclusively within the engineering community
and society at large, such as being able to comprehend and write effective reports and design
documentation, make effective presentations considering cultural, language, and learning differences.
PO10: Project Management and Finance: Apply knowledge and understanding of engineering
management principles and economic decision-making and apply these to one’s own work, as a
member and leader in a team, and to manage projects and in multidisciplinary environments.
PO11: Life-Long Learning: Recognize the need for, and have the preparation and ability for
(i) Independent and life-long learning
(ii) Adaptability to new and emerging technologies and
(iii) Critical thinking in the broadest context of technological change.(WK8)
Program Specific Outcomes for Computer Science Engineering
After completion of the course, students will be able to:
Apply software engineering principles and practices for developing quality software for
PSO1
Scientific and business applications to meet societal needs.
Adapt to emerging information and communication tools and technologies(ICT)to innovate
PSO2
Ideas and solutions to existing/novel problems.
COURSE OBJECTIVES:
To learn the basic concepts and terminology of DevOps.
To gain knowledge on Devops platform.
To understand building and deployment of code.
To be familiar with DevOps automation tools.
To learn basics of MLOps.
LIST OF EXPERIMENTS:
1. Creating a new Git repository, cloning existing repository, Checking changes into a Git repository, Pushing
changes to a Git remote, Creating a Git branch
2. Installing Docker container on windows/Linux, issuing docker commands
3. Building Docker Images for Python Application
4. Setting up Docker and Maven in Jenkins and First Pipeline Run
5. Running Unit Tests and Integration Tests in Jenkins Pipeline
SOFTWARE REQUIRED:
GitHub
COURSECODE & NAME: P24CSPE13 & DEVOPS AND MICROSERVICES
Knowledge
No. COURSE OUTCOME (CO) Level
CO-PO MAPPING
POs
CO PO1 PO2 PO3 PO4 PO5 PO6
1 2 2 1 3 3 3
2 2 - 1 2 2 2
3 2 1 1 3 3 3
4 2 1 2 2 1 1
5 2 - - 2 1 1
AVG 2 1.3 1.25 2.4 2 2
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
M.E. COMPUTER SCIENCE AND ENGINEERING (WITH SPECIALIZATION IN ARTIFICAIL INTELLIGENCE AND
MACHINE LEARNING)
Registration No
Name of the Evaluator
AIM:
To creating a new Git repository, cloning existing repository,
checkin changes into a Git repository, pushing changes to a
Git remote, creating a Git branch.
2
II. CLONING EXISTING REPOSITORY
5. Change the current working directory to the location where you want the cloned directory.
6. Type git clone, and then paste the URL you copied earlier.
$ git clone [Link]
4
6. Click Create branch.
CONCLUSION:
Successfully executed the above operations on local and remote Git Repositories and
outputs were captured.
5
[Link]: 2 INSTALLING DOCKER CONTAINER ON
Date: WINDOWS/LINUX, ISSUING DOCKER COMMANDS
AIM:
To install Docker container on Windows/Linux and issuing docker commands.
Output
When we run above command, we will get the following result −
From the output, we can see that the Linux kernel version is 4.2.0-27 which is higher than version 3.8, so
we are good to go.
Step 2 − Need to update the OS with the latest packages, which can be done via the following command −
apt-get
This method installs packages from the Internet on to the Linux system.
Syntax
sudo apt-get
update Return
Value None
6
Example
sudo apt-get update
Output
When we run the above command, we will get the following result −
This command will connect to the internet and download the latest system packages for Ubuntu.
Step 3 − The next step is to install the necessary certificates that will be required to work with the Docker site
later on to download the necessary Docker packages. It can be done with the following command.
sudo apt-get install apt-transport-https ca-certificates
Step 4 − The next step is to add the new GPG key. This key is required to ensure that all data is encrypted when
downloading the necessary packages for Docker.
7
Step 5 − Next, depending on the version of Ubuntu you have, you will need to add the relevant site to the
[Link] for the apt package manager, so that it will be able to detect the Docker packages from the
Docker site and download them accordingly.
Since our OS is Ubuntu 14.04, we will use the Repository name as
“deb [Link] main”.
And then, we will need to add this repository to the [Link] as mentioned above.
Step 6 − Next, we issue the apt-get update command to update the packages on the Ubuntu system.
8
Step 7 − If you want to verify that the package manager is pointing to the right repository, you can do it by
issuing the apt-cache command.
apt-cache policy docker-engine
In the output, you will get the link to [Link]
Step 8 − Issue the apt-get update command to ensure all the packages on the local system are up to date.
9
Step 9 − For Ubuntu Trusty, Wily, and Xenial, we have to install the linux-image-extra-* kernel packages,
which allows one to use the aufs storage driver. This driver is used by the newer versions of Docker.
sudo apt-get install linux-image-extra-
$(uname -r) linux-image-extra-virtual
Step 10 − The final step is to install Docker and we can do this with the following command −
sudo apt-get install –y docker-engine
Here, apt-get uses the install option to download the Docker-engine image from the Docker website and get
Docker installed.
The Docker-engine is the official package from the Docker Corporation for Ubuntu-based systems.
1
0
II. ISSUING DOCKER COMMANDS
1. Docker Version
To see the version of Docker running, you can issue the following command −
Syntax
docker version
Return Value
The output will provide the various details of the Docker version installed on the system.
Example
sudo docker version
Output
When we run the above program, we will get the following result −
2. Docker Info
To see more information on the Docker running on the system, you can issue the following command −
Syntax
docker info
Example
sudo docker info
11
Output
When we run the above command, we will get the following result −
Following command lines can be used to install docker desktop on windows 10, 11 or higher versions
1. To run in terminal,
"Docker Desktop [Link]" install
1
2
2. For Powershell,
Start-Process '.\win\build\Docker Desktop [Link]' -Wait install
4. To add user accounts into docker user groups especially when your admin account and user account
are not the same.
net localgroup docker-users <users>/add
CONCLUSION:
Successfully installed the docker containers in Windows and Linux and verified docker commands.
1
3
[Link]: 3 BUILDING DOCKER IMAGES FOR PYTHON
Date: APPLICATION
AIM:
To build docker images for Python application.
PROCEDURE:
1. Setting Up the Dockerfile
First, going to set up the Dockerfile, which is a sequential set of commands used in building the
Docker image. For this, you’ll use python unbuffered, a Python environmental variable that
allows the Python output to be sent straight to the terminal when set to a non-empty string or
executed with the -u option on the command line.
This is useful when log messages are needed in real time. It also prevents issues such as the
application crashing without giving relevant details due to the message being “stuck” in a buffer.
Create a project directory and change into the directory using cd <directory_name>:
Run the commands below to create a virtual environment. This isolates the environment for
the Python project, so that it won’t affect or be affected by other Python projects running on
the local environment. Any dependencies installed won’t interfere with other Python projects.
>_python3 -m venv
<directory_name> source
<directory_name>/bin/activate
Using the following code, create a new file called Dockerfile in the empty project directory:
>_FROM python:3.8-slim-buster
1
4
ENV PYTHONUNBUFFERED=1
WORKDIR /app
This code pulls the base image from python:3.8-slim-buster and ensures the output is sent
straight to the terminal. It confirms the current working directory location, the Python app to be
copied to the current directory, and the packages in [Link] to be installed.
@[Link]('/')
def hello_world():
Save and close. This creates a simple Python web app that shows Hello, Docker! text.
Create the [Link] file. This should contain the dependencies needed for the app to
1
5
Run the following command in the terminal to install the Flask framework needed to run the
Python app and add them to the [Link] file. pip3 freeze shows all packages installed
via pip.
[Link]=2.0.3
pylint
Test the app to see if it works by using python3 -m flask run --host=[Link] --port=5000 and
then navigating to [Link] in your preferred browser:
Now that the Dockerfile, [Link], and [Link] have been created, you should test the
Python app on your local environment to make sure it works.
Going to build the Docker image from the created Dockerfile. This image is a set of read-
only commands used in the building and deployment of Docker containers.
To build the Docker image, use the docker build --tag dockerpy . command. It is common
practice to use tags; Docker will give the image a default latest tag.
1
6
4. Docker build
Type docker images into the terminal to view the newly created image:
1
7
5. Building the container
Now test application using [Link] on your preferred browser. You’ve run your Python
app inside a Docker container.
The container image can be pushed and retrieved from the Docker Hub registry. Docker Hub
is an open source library and community for container images. Pushed images can be shared
among teams, customers, and communities. It uses a single command, docker push <hub-
user>/<repo- name>:<tag>.
To get a hub username, sign up on the website. Then, click Create Repository at the top
right corner of the page:
Creating repository
Creating a repo
1
8
7. Docker push for the created Python application
Copy the command on the right side of the page to your terminal, replacing tagname with a
version or with the word latest.
CONCLUSION:
Successfully built the docker image for Python application and outputs were captured.
1
9
[Link]: 4 SETTING UP DOCKER AND MAVEN IN JENKINS AND
Date: FIRST PIPELINE RUN
AIM:
To setting up Docker and Maven in Jenkins and first pipeline run.
PREREQUISITES:
● A macOS, Linux or Windows machine with:
● 10 GB of drive space for Jenkins and your Docker images and containers.
PROCEDURE:
1. Open up a terminal window.
2. Create a bridge network in Docker using the following docker network create command:
docker run \
--name jenkins-docker \
--rm \
--detach \
--privileged \
--network jenkins \
--network-alias docker \
--env DOCKER_TLS_CERTDIR=/certs \
--volume jenkins-docker-certs:/certs/client \
--volume jenkins-data:/var/jenkins_home \
--publish 2376:2376 \
--publish 3000:3000 --publish
5000:5000 \ docker:dind \
--storage-driver overlay2
docker run --name jenkins-docker --rm --detach \
--privileged --network jenkins --network-alias docker \
--env DOCKER_TLS_CERTDIR=/certs \
--volume jenkins-docker-certs:/certs/client \
--volume jenkins-data:/var/jenkins_home \
2
0
--publish 3000:3000 --publish 5000:5000 --publish 2376:2376
\ docker:dind --storage-driver overlay2
5. Customise official Jenkins Docker image, by executing below two steps:
Create Dockerfile with the following content:
FROM jenkins/jenkins:2.387.1
USER root
RUN apt-get update && apt-get install -y lsb-release
RUN curl -fsSLo /usr/share/keyrings/[Link]
\ [Link]
RUN echo "deb [arch=$(dpkg --print-architecture) \
signed-by=/usr/share/keyrings/[Link]] \
[Link] \
$(lsb_release -cs) stable" > /etc/apt/[Link].d/[Link]
RUN apt-get update && apt-get install -y docker-ce-cli
USER jenkins
RUN jenkins-plugin-cli --plugins "blueocean docker-workflow"
6. Build a new docker image from this Dockerfile and assign the image a meaningful name,
e.g. "myjenkins-blueocean:2.387.1-1":
docker build -t myjenkins-blueocean:2.387.1-1 .
7. Keep in mind that the process described above will automatically download the official Jenkins
Docker image if this hasn’t been done before.
docker run \
--name jenkins-blueocean \
--detach \
--network jenkins \
--env DOCKER_HOST=tcp://docker:2376 \
--env DOCKER_CERT_PATH=/certs/client \
--env DOCKER_TLS_VERIFY=1 \
--publish 8080:8080 \
--publish 50000:50000 \
--volume jenkins-data:/var/jenkins_home \
--volume jenkins-docker-certs:/certs/client:ro \
--volume "$HOME":/home \
--restart=on-failure \
--env JAVA_OPTS="-
[Link].ALLOW_LOCAL_CHECKOUT=true" \ myjenkins-
blueocean:2.387.1-1
docker run --name jenkins-blueocean --detach \
--network jenkins --env DOCKER_HOST=tcp://docker:2376
2 \
--env DOCKER_CERT_PATH=/certs/client 1--env DOCKER_TLS_VERIFY=1 \
--publish 8080:8080 --publish 50000:50000 \
--volume jenkins-data:/var/jenkins_home \
--volume jenkins-docker-certs:/certs/client:ro \
--volume "$HOME":/home \
--restart=on-failure \
--env JAVA_OPTS="-
[Link].ALLOW_LOCAL_CHECKOUT=true" \ myjenkins-
9. Proceed to the Post-installation setup wizard.
blueocean:2.387.1-1
The Jenkins project provides a Linux container image, not a Windows container image. Be sure
that your Docker for Windows installation is configured to run Linux Containers rather than
Windows Containers. See the Docker documentation for instructions to switch to Linux
containers. Once configured to run Linux Containers, the steps are:
10. Open up a command prompt window and similar to the macOS and Linux instructions
above do the following:
2
3
18. Copy the following Declarative Pipeline code and paste it into your empty Jenkinsfile:
pipelin
e{
agent {
docker {
image 'maven:3.9.0-eclipse-temurin-11'
args '-v /root/.m2:/root/.m2'
}
}
stages {
stage('Build') {
steps {
sh 'mvn -B -DskipTests clean package'
}
}
}
}
19. Downloads the Maven Docker image and runs it in a container on Docker.
2
4
20. Runs the Build stage (defined in the Jenkinsfile) on the Maven container. During this time,
Maven downloads many artifacts necessary to build your Java application, which will
ultimately be stored in Jenkins’s local Maven repository (in the Docker host’s filesystem).
2
5
Output of the "Deliver" stage,
CONCLUSION:
Successfully created Docker and Maven in Jenkins and outputs were captured.
2
6
[Link]: 5 RUNNING UNIT TESTS AND INTEGRATION TESTS IN
Date: JENKINS PIPELINES
AIM:
To run Unit tests and Integration tests in Jenkins pipelines.
1. Go to the Jenkins dashboard and Click on the existing HelloWorld project and choose the
Configure option
2
7
2. Browse to the section to Add a Build step and choose the option to Invoke Ant.
2
8
4. In the build file section, enter the location of the [Link] file.
5. Next click the option to Add post-build option and choose the option of “Publish Junit test result report”
2
9
6. In the Test reports XML’s, enter the location as shown below. Ensure that Reports is a folder
which is created in the HelloWorld project workspace. The “*.xml” basically tells Jenkins to
pick up the result xml files which are produced by the running of the Junit test cases. These xml
files which then be converted into reports which can be viewed later.
3
0
7. Once saved, you can click on the Build Now option.
Once the build is completed, a status of the build will show if the build was successful or not. In the
Build output information, you will now notice an additional section called Test Result. In our case,
we entered a negative Test case so that the result would fail just as an example.
One can go to the Console output to see further information. But what’s more interesting is that if you
click on Test Result, you will now see a drill down of the Test results.
3
1
II. RUNNING INTEGRATION TESTS IN JENKINS PIPELINES:
1. Go to Manage Plugins.
2. Find the Hudson Selenium Plugin and choose to install. Restart the Jenkins instance.
3
2
3. Go to Configure system.
4. Configure the selenium server jar and click on the Save button.
3
3
Note − The selenium jar file can be downloaded from the location
SeleniumHQ Click on the download for the Selenium standalone server.
5. Go back to your dashboard and click on the Configure option for the HelloWorld project.
3
4
6. Click on Add build step and choose the optin of “SeleniumHQ htmlSuite Run”
7. Add the necessary details for the selenium test. Click on Save and execute a build. Now the post
build will launch the selenium driver, and execute the html test.
CONCLUSION:
Successfully ran the Unit and Integration tests in Jenkins and outputs were captured.
3
5