0% found this document useful (0 votes)
2K views25 pages

Dev Ops Lab Manual

This document provides information about the DevOps lab manual for computer science and engineering students. It outlines the vision, mission, program educational objectives, program outcomes and program specific outcomes of the computer science department and engineering program. The document aims to guide students in their DevOps lab work.

Uploaded by

Mukesh Gilda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views25 pages

Dev Ops Lab Manual

This document provides information about the DevOps lab manual for computer science and engineering students. It outlines the vision, mission, program educational objectives, program outcomes and program specific outcomes of the computer science department and engineering program. The document aims to guide students in their DevOps lab work.

Uploaded by

Mukesh Gilda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

lOMoARcPSD|39709108

Dev Ops-lab-Manual

Devops (Jawaharlal Nehru Technological University, Hyderabad)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by J Naresh Kumar (naresh5021@[Link])
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

DEPARTMENT OF COMPUTER SCIENCE ENGINEERING (AI & ML)

DEVOPS LAB MANUAL

Subject Code :
Regulation : R18/JNTUH

Year : 2022-2023

III B. TECH II SEMESTER

COMPUTER SCIENCE AND ENGINEERING (AI &ML)


KG REDDY COLLEGE OF ENGINEERING AND TECHNOLOGY
Affiliated o JNTUH, Chilkur,(V), Moinabad(M) R. Dist, TS-501504

DevOps Lab CSE(AI&ML) Assist Prof: Devdas

Downloaded by J Naresh Kumar (naresh5021@[Link])


lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

DEPARTMENT OF COMPUTER SCIENCE AND


ENGINEERING (AI & ML)
VISION AND MISSION OF THE INSTITUTION
VISION
To become self-sustainable institution this is recognized for its new age engineering through
innovative teaching and learning culture, inculcating research and entrepreneurial ecosystem, and
sustainable social impact in the community.
MISSION
 To offer undergraduate and post-graduate programs that is supported through industry relevant
curriculum and innovative teaching and learning processes that would help students succeed in their
professional careers.
 To provide necessary support structures for students, this will contribute to their personal and
professional growth and enable them to become leaders in their respective fields.
 To provide faculty and students with an ecosystem that fosters research and development through
strategic partnerships with government organisations and collaboration with industries.
 To contribute to the development of the region by using our technological expertise to work with nearby
communities and support them in their social and economic growth.

VISION AND MISSION OF CSE DEPARTMENT


VISION
To be recognized as a department of excellence by stimulating a learning environment in which
students and faculty will thrive and grow to achieve their professional, institutional and societal
goals.
MISSION
 To provide high quality technical education to students that will enable life-long learning and
build expertise in advanced technologies in Computer Science and Engineering.
 To promote research and development by providing opportunities to solve complex
engineering problems in collaboration with industry and government agencies.
 To encourage professional development of students that will inculcate ethical values
and leadership skills while working with the community to address societal issues.

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING (AI&ML)

PROGRAM EDUCATIONAL OBJECTIVES (PEOS):


A graduate of the Computer Science and Engineering Program should:
Program Educational Objective1: (PEO1)
PEO1
The Graduates will provide solutions to difficult and challenging issues in their profession
by applying computer science and engineering theory and principles.
Program Educational Objective2 :( PEO2)
PEO2
The Graduates have successful careers in computer science and engineering fields or will be
able to successfully pursue advanced degrees.
Program Educational Objective3: (PEO3)
PEO3
The Graduates will communicate effectively, work collaboratively and exhibit high levels of
Professionalism, moral and ethical responsibility.
Program Educational Objective4 :( PEO4)
PEO4
The Graduates will develop the ability to understand and analyse Engineering issues in a
broader perspective with ethical responsibility towards sustainable development.

PROGRAM OUTCOMES (POS):

Engineering knowledge: Apply the knowledge of mathematics, science, engineering


PO1
Fundamentals andanengineeringspecializationtothesolutionofcomplexengineeringproblems.
Problem analysis: Identify, formulate, review research literature, and analyze complex
PO2 engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
Design/development of solutions: Design solutions for complex engineering problems and
PO3 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.
Conduct investigations of complex problems: Use research-based knowledge and research
PO4 methods including design of experiments, analysis and interpretation of data, and synthesis of
the information to provide valid conclusions.

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
PO5 engineering and IT tools including prediction and modeling to complex engineering activities
with an understanding of the limitations.
The engineer and society: Apply reasoning informed by the contextual knowledge to assess
PO6 societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to
the professional engineering practices.
Environment and sustainability: Understand the impact of the professional engineering
PO7 Solutions in societal and environmental contexts, and demonstrate the knowledge of, and need
for sustainable development.
Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
PO8
norms of the engineering practice.
Individual and team work: Function effectively as an individual, and as a member or leader
PO9
in diverse teams, and in multi-disciplinary settings.
Communication: Communicate effectively on complex engineering activities with the
PO10 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.
Project management and finance: Demonstrate knowledge and understanding of the
PO11 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.
Life-long learning: Recognize the need for, and have the preparation and ability to engage in
PO12
independent and life-long learning in the broadest context of technological change.

PROGRAM SPECIFIC OUTCOMES (PSOS):

Problem Solving Skills – Graduate will be able to apply computational techniques and
PSO1
software principles to solve complex engineering problems pertaining to software engineering.
Professional Skills – Graduate will be able to think critically, communicate effectively, and
PSO2
collaborate in teams through participation in co and extra-curricular activities.
Successful Career – Graduates will possess a solid foundation in computer science and
PSO3 engineering that will enable them to grow in their profession and pursue lifelong learning
through post-graduation and professional development.

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

[Link] List Of Experiments Page No


1 Write code for a simple user registration form for an event.

2 Explore Git and GitHub commands.

3 Practice Source code management on GitHub. Experiment with the


source code written in exercise 1.

4 Jenkins installation and setup, explore the environment.

5 Demonstrate continuous integration and development using Jenkins.

6 Explore Docker commands for content management.

7 Develop a simple containerized application using Docker.

8 Integrate Kubernetes and Docker

9 Automate the process of running containerized application


developed in exercise 7 using Kubernetes.

10 Install and Explore Selenium for automated testing.

11 Write a simple program in JavaScript and perform testing using


Selenium.

12 Develop test cases for the above containerized application using


selenium.

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

Experiment No: 1. Write a code for a simple user registration form for an event.

Aim: Write a code for a simple user registration form for an event.

DESCRIPTION: Here’s an example of a simple user registration form using Flask and Docker in DevOps:

 Create a Docker file with the following content to create a Docker image for your Flask application:

FROM Python: 3.8


WORKDIR /app
COPY. .
RUN pip install --no-cache-dir -r [Link]
EXPOSE 5000
CMD [“Python”, “[Link]”]

 Create a [Link] with the following content to list the dependencies of your
Flask application:Flask==1.1.2

 Create a [Link] file with the following code for a simple user registration form is Flask:

from flask import Flask, request, render_template


app= Flask(__name__)
@[Link](‘/register’, methods=[‘GET’, ‘POST’])
def register():
if [Link] == ‘POST’:
name = [Link][‘name’]
email=[Link][‘email’]
password=[Link][‘password’]
#store the user data in database or file
return render_template(‘[Link]’)
return render_template(‘[Link]’)
if __name__ ==’__main__’:
[Link](host=’[Link]’)

 Create an templates folder and add the following two files: [Link] and [Link].

[Link]
<form method =” post”>
<input type = “text” name = “name” placeholder = “n=Name”>
<input type =”email” name =”email” placeholder = “Email”>
<input type =”password” name = ”password” placeholder=”Password”>
<input type =”submit” value = ”Submit”>
</form>

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

[Link]
<h2> Registration Successful </h2>

 Build a docker image for your flask application using the following command:
docker build -t simple-flask-app.
 Run a docker container from the image using the following command:
docker run -p 5000:5000 simple-flask-app.
 Open the web browser access registration form at http:// localhost:5000/register

This example demonstrates how to build a simple user registration form in Flask and run it in a Docker
container in DevOps. Notes that this code is only meant to demonstrates the basic structure of user
registration form and does not include any security measure or proper error handling. It is highly
recommended to add security measures or proper error handling. It is highly recommended to add
security measure such as password hashing and validation before using it in a production environment.

VIVA QUESTIONS

1. Define Flask in DevOps

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

Experiment no: 2. Explore Git and Git Hub commands

Aim: Explore Git and Git Hub commands

Description: Git and Git Hub are two of the most popular tools used for version control and
collaboration in software development.

Here are some common Git and GitHub commands:

 Initializing a Git respository: $ git init


 Checking the status of the respository: $ git status
 Adding file to the stage: $ git add <file-name>
 Committing changes: $ git commit -m “commit message”
 Checking the commit history: $ git log
 Undoing changes: $ git checkout <file-name>
 Creating a new branch: $ git branch <branch-name>
 Switching to different branch: $ git checkout <branch-name>
 Merging two branches: $ git merge <branch-name>
 Pushing changes to a remote respository: $ git push origin <branch-name>
 Cloning a respository from GitHub: $ git clone <respository-url>
 Creating a pull request on GitHub: Go to the respository on GitHub, select the branch you want to
merge and click the “New pull request” button.

These are just a few of the many Git and GitHub commands available. There are many other Git
commands and functionalities that you can explore to suit your needs.

VIVA QUESTIONS

1. What is GitHub
2. Difference between Git and GitHub

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

Experiment no3. Practice Source code management on GitHub. Experiment with the source code
written in exercise 1.

Aim: Practice Source code management on GitHub. Experiment with the source code written in
exercise 1.

Description: To practice source code management on GitHub, you can follow this step:

 Create a GitHub account if you don’t already have one.


 Create a new respository on GitHub.
 Clone the respository to your local machine: $ git clone <respository-url>
 Move to the respository directory: $ cd <respository-name>
 Create a new file in the respository and add the source code written in exercise 1.
 Stage the changes: $ git add <file-name>
 Commit the changes: $ git commit -m “Added source code for a simple user registration form”
 Push the changes to the remote respository: $ git push origin master
 Verify that changes are reflected in the respository on GitHub

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.

VIVA QUESTIONS

1. What is GitHub management


s

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

Experiment no: 4. Jenkins installation and setup, explore the environment.

Aim: Jenkins installation and setup, explore the environment.

Description: Jenkins is a popular open-source tool for Continuous Integration and Continuous
Deployment (CI/CD) in software development. Here are the steps to install and set up Jenkins:

Download and Install Jenkins:


 Download the Jenkins package or your operating system from the Jenkins website.
 Follow the installation instructions for your operating system to install Jenkins.

Start the Jenkins service:


 On windows, use the Window Services Manager to start a Jenkins service.
 On Linux, use the following commands to start the Jenkins service: $ sudo service Jenkins start

Access 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 Jenkins login page.

Initialize the Jenkins environment:


 Follow the instruction on Jenkins setup wizard to initialize the Jenkins environment.
 This process involves installing recommended plugins, setting up security and creating a first
admin user.

Explore the Jenkins environment:


 Once the Jenkins environment set up, you can explore the various feature and functionalities available
in the web interface.
 Jenkins as 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.

VIVA QUESTIONS

1. Define Jenkins

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

Experiment no: 5. Demonstrate continuous integration and development using Jenkins.

Aim: Demonstrate continuous integration and development using Jenkins.

Description: continuous integration (CI) and continuous development (CD) are important practice
in software development that can be achieved using Jenkins. Here’s the example of how you
can demonstrate CI/CD using Jenkins:

 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 respository:


 Create a git respository for an application and commit the code to respository.
 Make sure that the Git respository is accessible from the Jenkins server.

Create a Jenkins jobs:


 Log in to the Jenkins web interface and create a new job.
 Configure the job to build the Java application from the Git respository.
 Specify the build triggers, such as building after every commit to respository.

Build the application:


 Trigger the build application using Jenkins job.
 The build should compile the code, run any test, and produce an executable jar file.

Monitor the build:


 Monitor the build progress in the Jenkins web interface.
 The build should show the build log, test result, and the status of the build.

Deploy the application:


 If the build is successful, configure the Jenkins job to deploy the application to a production
environment.
 Jenkin should automatically build and deploy the changes to the production environment.

This is basic example of how you can use Jenkins to demonstrate CI/CD in software development. In real
world scenario, you would likely have more complex requirements, such as multiple environments,
different types of tests, and more sophisticated deployment process. However, this example should give you
a good starting point for using Jenkins CI/CD in your software development projects.

VIVA QUESTIONS

1. Define CD & CI

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

Experiment no: 6. Explore Docker commands for content management.

Aim: Explore Docker commands for content management.

Description: Docker is a containerization technology that is widely used for managing application
containers. Here are some commonly used Docker commands for content management:

 Docker run: Run a command in a new container.


For example: $ docker run --name mycontainer -it ubuntu:16.04/bin/bash
This command runs a new container based on ubuntu 16.04 image and starts a shell session in
the container.

 Docker start: start one or more stopped containers.


For example: $ docker start mycontainer
This command starts a container named “mycontainer”.

 Docker stop: stop one or more running containers.


For example: $ docker stop mycontainer.
This command stops a container named “mycontainer”

 Docker rm: Remove one or more containers.


For example: $ docker rm mycontainer
This command removes a container named “mycontainer”

 Docker ps: List containers.


For example: $ docker ps
This command lists all running containers.

 Docker images: List images


For example: $ docker images
This command lists all images stored locally on the host

 Docker pull: pull an image or a respository from a registry.


For example: $ docker pull ubuntu:16.04
This command pulls the ubuntu 16.04 image from the Docker Hub registry.

 Docker push: push an image or a respository form a registry


For example: $ docker push myimage
This command pushes the image named “myimage” to the Docker Hub registry.

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

These are some of the basic Docker commands for managing containers and images. There are many
Docker commands and options that you can use for more advanced use cases, such as managing
networks, volumes and configuration. However, these commands should give a good starting point for
using Docker for content management.

VIVA QUESTIONS

1. Give briefly about Docker commands

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

Experiment no:7. Develop a simple containerized application using Docker

Aim: Develop a simple containerized application using Docker

Description: Here an example of how you can develop a simple containerized application using Docker:

Choose an application:
 Choose a simple application that you want to containerize. For example, a python script that
prints “Hello World”.

Write a Dockerfile:
 Create a file named “Dockerfile” in the same directory as the application.

In the dockerfile, specify the base image, copy the application into the container, and specify the command
to run the application. Here’s an example for a Python script:

#Use the official Python image as the base image


FROM python:3.9

#Copy the python script into the container


COPY [Link]/app/

#Set the working directory to/app/


WORKDIR/app/

#Run the Python script when the container starts


CMD [“python”, “[Link]”]

 Build the Docker image:


Run the following command to build the docker image: $ docker build -t myimage .

The command builds a new Docker image using the Dockerfile and tag 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 by named “mycontainer” based on the “myimage” image and run
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.

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

This is the simple example of how you can use Docker to containerize an application. In the
real-world scenario, you would likely have more complex requirements such as running multiple
containers, managing network connections, and persisting data. However, this example should give
you a good starting point for using Docker to containerize your applications.

VIVA QUESTIONS

1. Name the application using Docker

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

Experiment no: 8. Integrate Kubernetes and Docker

Aim: Integrate Kubernetes and Docker

Description: Kubernetes and Docker are both popular technologies for managing containers, but they are
used for different purposes. Kubernetes is an orchestration platform that provides a higher-level abstraction
for managing containers, while Docker is a containerization technology that provides a lower-level runtime
for containers.

To integrate Kubernetes and Docker, you need to use Docker to build and package you
application as a container image, and then use Kubernetes to manage and orchestrate the
containers.

Here’s a high-level overview of the steps to integrate Kubernetes and Docker:

 Build a docker image:


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.

 Push the Docker image to a registry:


Push the Docker image to a container registry. Such as Docker Hub or Google Container Registry,
so that is can be easily accessed by Kubernetes. Deploy the Docker image to a Kubernetes cluster.

Use Kubernetes to deploy the Docker image to a cluster. This involves creating a deployment that specifies
the number of replicas and the image to be used, and creating a service that expose the deployment to
the network.

 Monitor and manage the containers: Use Kubernetes to monitor and manage the containers. This
includes the scaling the number of replicas, update the image, and rolling out updates to the containers.
 Continuously integrate and deploy changes: Use a continuous integration and deployment (CI/CD)
pipeline to automatically build, push and deploy changes to the docker image and Kubernetes cluster.
This makes it easier to make updates to the application and ensure that the latest version is always
running in the cluster. By integrating Kubernetes and docker, you can leverage the strength of both
technologies to manage container in a scalable, reliable and efficient manner.

VIVA QUESTIONS

1. What is docker?

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

Experiment no:9. Automate the process of running containerized application developed in exercise
7 using Kubernetes.

Aim: Automate the process of running containerized application developed in exercise 7


using Kubernetes.

Description: To automate the process of running the containerized application developed in exercise 7
using Kubernetes, you can follow these steps:

 Create a Kubernetes cluster: Create a Kubernetes cluster that cloud provided such as google cloud or
amazon web services, or using local installation of Minikube.
 Push the Docker image to registry: Push the Docker image of your application to a container
registry, such as Docker Hub or Google Container Registry.
 Create a deployment: Create a deployment in Kubernetes that specifies the number of replicas and
the Docker image to use. Here’s an example of a deployment YAML file:

apiVersion:apps/v1
kind: Deployment
metadata:
name:myapp
spec:
replicas:3
selector:
matchLabels:
app:myapp
template:
metadata:
labels:
app:myapp
spec:
container:
-name: myapp
image: myimage
ports:
-container Port:80

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

 Create a service: Create a service in Kubernetes that exposes the deployment to the network.
Here’s an example of a service YAML file:
apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
selector:
app: myapp
ports:
-name: http
Port:80
targetPort:80
Type: clusterIP

 Apply the deployment and service to the cluster: Applying the deployment and service to the cluster
using the kubect1 command- line tool. For example:
$ kubect1 apply -f [Link]
$ kubect1 apply -f [Link]

 Verify the deployment: Verify the deployment by checking the status of the pods and the service. For
example:
$ kubect1 get pods
$ kubect1 get services

This is the basic example of how to automate the process of running a containerized application using
Kubernetes. In the real-world scenarios, you would likely have more complex requirements. Such as
managing persistent data, scaling and rolling updates, but this example gives you a good starting point
for using Kubernetes to manage your containers.

VIVA QUESTIONS

1. Define Kubernetes

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

Experiment no:10. Install and explore selenium for automated testing

Aim: Install and explore selenium for automated testing

Description: To install and explore selenium for automated testing, you can follow the steps:

Install java development kit (JDK):

 Selenium is written in Java, so you will need to install JDK in order to run it. You can download and
install JDK form the official Oracle website
 Install the Selenium WebDriver:
 You can download the latest version of Selenium WebDriver from the selenium website. You will also
need to download the appropriate driver for your web browser of choice (e.g: Chrome Driver for
Google Chrome)

Install an Integrated Development Environment (IDE):

 To write and run Selenium tests, you will need an IDE. Some popular choices include Eclipse, IntelliJ
IDEA, and Visual Studio Code.
 Write a simple test:
 Once you have an IDE setup, you can write a simple test using the Selenium WebDriver. Here’s an
example in Java:

import [Link],WebDriver;
import [Link];
public class Main {
public static void main (string [] arg) {
[Link](“[Link]”, “path/to/chromedriver”);
WebDriver driver = new ChromeDriver();
[Link]([Link]
[Link]([Link]());
[Link]();

 Run the test: Run the test using your IDE or from the command line using the following command:

$ javac [Link]
$ javac Main

This is a basic example of how to get started with Selenium for automated testing. In a real-world scenario,
you would likely write more complex tests and organize your code into test suites and test cases but this
example should give you a good starting point for exploring Selenium.

VIVA QUESTIONS

1. What is automation testing and list the automation testing

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

Experiment no: 11. Write a simple program in JavaScript and perform testing using Selenium

Aim: Write a simple program in JavaScript and perform testing using Selenium

Program: Simple JavaScript program that you can test using Selenium

<!DOCTYPE html>
<html>
<head>
<title> Simple JavaScript Program </title>
</head>
<body>
<p id=”output”>0</p>
<button id=”increment-button”> Increment </button>
<script>
const output= [Link](“output”);
const incrementButton=[Link](“increment-button’);
let count=0;
[Link](“click”, function () {
count +=1;
[Link]=count;
});
</script>
</body>
</html>

 Write a test case for this program using Selenium

Import [Link];
Import [Link];
Import [Link];
Import [Link];
Import [Link];
Import [Link];
Public class Main {
Private WebDriver driver;
@Before
Public void setUp(){
[Link](“[Link]”, “path/to/chromedriver”);
driver= new ChromeDriver();
}

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

@Test
Public void testIncrementButton()
{
[Link]([Link]
[Link]([Link](“increment-button”)).click();
String result = [Link]([Link](“output”)).getText();
assert [Link](“1”);
}

@After
Public void tearDown()
{
[Link]();
}
}

You can run the test case using the following commands:

$ javac [Link]
$ javac Main
The output of the test case should be:
Time: 0.189
OK (1 test)

This output indicates the test case passed, and the increment button was successfully clicked, causing the output
to be incremented by 1.

VIVA QUESTIONS

1. How java can be useful by using selenium

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

Experiment: 12. Develop test cases for the above containerized application using Selenium.

Aim: Develop test cases for the above containerized application using Selenium.

Program: Here is an example of how you could write test cases for the containerized application
using selenium.

Import [Link];
Import [Link];
Import [Link];
Import [Link];
Import [Link];
Import [Link];

Public class Main


{
Private WebDriver driver;

@Before
Public void setUp() {
[Link](“[Link]”, “path/to/chromedriver”);
driver= new ChromeDriver();
}

@Test
Public void testHomePageLoad() {
[Link]([Link]
String title = driver getTitle();
assert [Link](“ My Conternerized Application”);
}

@Test
Public void testSubmitForm() {
[Link]([Link]
[Link]([Link](“name”)).sendKeys(“John Deo”);
[Link]([Link](“email”)).sendkeys(“[Link]@[Link]”);
[Link]([Link](“submit”)).click();
String result = [Link]([Link](“result”)).getText();
assert [Link](“Form submitted successfully!”);
}

@After
Public void tearDown(){
[Link]();
}
}

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

KG Reddy College of Engineering & Technology


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)
Chilkur (Village), Moinabad (Mandal), R. R Dist, TS-501504

You can run the test cases using the following command:

$ [Link]
$ [Link]
The output of test cases should be:
..

Time: 1.135
OK (2 test)

This output indicates that both test case passed, and the containerized application is functioning as expected.

VIVA QUESTIONS

1. Define selenium
2. Name the test case used in selenium

Downloaded by J Naresh Kumar (naresh5021@[Link])


DevOps Lab CSE(AI&ML) Assist Prof: Devdas
lOMoARcPSD|39709108

DevOps Lab CSE(AI&ML)


Downloaded by J Naresh Kumar (naresh5021@[Link])
Assist Prof: Devdas

You might also like