Devops Lab Manual Programs
Devops Lab Manual Programs
lOMoARcPSD|10553940
event. DESCRIPTION:
Here's an example of a simple user registration form using Flask and Docker
in DevOps:
FROM python:3.8
WORKDIR /app
COPY . .
EXPOSE 5000
file return
lOMoARcPSD|10553940
render_template('success.html')
lOMoARcPSD|10553940
return render_template('register.html')
VIVA QUESTIONS
Define Flask in devops
lOMoARcPSD|10553940
VIVA QUESTIONS
Define Git
What is Git Hub
Difference between Git & Git Hub
lOMoARcPSD|10553940
Description:
To practice source code management on GitHub, you can follow these steps:
• Create a GitHub account if you don't already have one.
• Create a new repository on GitHub.
• Clone the repository to your local machine: $ git clone <repository-
url>
• Move to the repository directory: $ cd <repository-name>
• Create a new file in the repository 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 repository: $ git push origin master
• Verify that the changes are reflected in the repository 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
DESCRIPTION
example, you may need to configure build agents, set up build pipelines, or
lOMoARcPSD|10553940
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
Define Jenkins
lOMoARcPSD|10553940
VIVA QUESTIONS
Define CD & CI
lOMoARcPSD|10553940
DESCRIPTION
Docker is a containerization technology that is widely used for managing
application containers. Here are some commonly used Docker commands for
content management:
These are some of the basic Docker commands for managing containers and
images. There are many other 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 you a good starting
point for using Docker for content management.
VIVA QUESTIONS
Docker DESCRIPTION
Choose an application:
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.
VIVA QUESTIONS
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 abstractions 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 your application as a container image, and then use Kubernetes to
manage and orchestrate the containers.
Use Docker to build a Docker image of your application. You can use a
Dockerfile to specify the base image, copy the application into the container,
and specify the command to run the application.
Use Kubernetes to monitor and manage the containers. This includes scaling
the number of replicas, updating the image, and rolling out updates to the
containers.
• Continuously integrate and deploy changes:
Viva questions:
Define integrate Kubernetes
What is Docker
lOMoARcPSD|10553940
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 using a cloud provider, such as Google Cloud or
Amazon Web Services, or using a local installation of Minikube.
• Push the Docker image to a 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
lOMoARcPSD|10553940
spec:
containers:
- name: myapp
image: myimage
ports:
- containerPort: 80
• 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:
Apply the deployment and service to the cluster using the kubectl command-
line tool. For example:
$ kubectl apply -f deployment.yaml
$ kubectl apply -f service.yaml
• Verify the deployment:
Verify the deployment by checking the status of the pods and the service.
For example:
$ kubectl get pods
lOMoARcPSD|10553940
VIVA QUESTIONS
Define Kubernetes
lOMoARcPSD|10553940
DESCRIPTION:
To install and explore Selenium for automated testing, you can follow these
steps:
• To write and run Selenium tests, you'll need an IDE. Some popular
choices include Eclipse, IntelliJ IDEA, and Visual Studio Code.
• Once you have your IDE set up, you can write a simple test using the
Selenium WebDriver. Here's an example in Java:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
System.out.println(driver.getTitle());
driver.quit();
}
}
$ javac Main.java
$ java 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
lOMoARcPSD|10553940
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 = document.getElementById("output");
const incrementButton =
document.getElementById("increment-button");
let count = 0;
incrementButton.addEventListener("click", function() {
count += 1;
output.innerHTML = count;
});
</script>
</body>
</html>
lOMoARcPSD|10553940
@Before
public void setUp() {
System.setProperty("webdriver.chrome.driver", "path/to/chromedriver");
driver = new ChromeDriver();
}
@Test
public void testIncrementButton() {
driver.get("file:///path/to/program.html");
driver.findElement(By.id("increment-button")).click();
String result = driver.findElement(By.id("output")).getText();
assert result.equals("1");
}
@After
public void tearDown() {
driver.quit();
}
}
You can run the test case using the following command:
$ javac Main.java
$ java Main
The output of the test case should be:
.
Time: 0.189
OK (1 test)
This output indicates that the test case passed, and the increment button was
successfully clicked, causing the output to be incremented by 1.
lOMoARcPSD|10553940
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 org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@Before
public void setUp() {
System.setProperty("webdriver.chrome.driver", "path/to/chromedriver");
driver = new ChromeDriver();
}
@Test
public void testHomePageLoads()
{
driver.get("http://localhost:8080");
String title = driver.getTitle();
assert title.equals("My Containerized Application");
}
@Test
public void testSubmitForm() {
driver.get("http://localhost:8080");
driver.findElement(By.name("name")).sendKeys("John Doe");
driver.findElement(By.name("email")).sendKeys("[email protected]
m");
driver.findElement(By.name("submit")).click();
lOMoARcPSD|10553940
@After
public void tearDown() {
driver.quit();
}
}
You can run the test cases using the following command:
$ javac Main.java
$ java Main
The output of the test cases should be:
..
Time: 1.135
OK (2 tests)
This output indicates that both test cases passed, and the containerized
application is functioning as expected.