DevOps Guide
DevOps Guide
Index
Creating a GitHub
1 12-02-2025 Repository and
Managing
Version Control
Using Command
Line
Jenkins
2 21-02-2025
Installation
Jenkins Pipeline
3 27-02-2025
Creation
Setting Up a
Simple Python
4 03-03-2025
Application with
Docker
Setting Up a
Simple Python
5 10-03-2025
Application with
Docker
Docker Compose:
6 16-03-2025
Multi-Container
DevOps 1
Sr. No. Date Program List Pg. No Sign
Kubernetes Setup
on Windows 11
8 12-04-2025
(Minikube +
Docker)
Grafana +
Prometheus
Setup on
9 24-04-2025
Windows 11
(Locally with
Docker)
1. Prerequisites:
b. Click on the "+" icon at the top right corner and select "New repository".
DevOps 2
iv. Initialize with a README: (uncheck this if you want to create locally)
cd /path/to/your/project
git init
a. Copy the URL of your GitHub repository (from the "Quick setup" page
after creating the repository on GitHub).
git add .
DevOps 3
git commit -m "Initial commit"
The -u flag sets the upstream for the master branch, meaning future git
d. You could encounter the problem of setting your identity first before
uploading the code to your remote repository; the solution is
The -u flag sets the upstream for the master branch, meaning future git
git status
git add .
DevOps 4
You can also stage specific files by replacing . with the filenames.
git push
git log
git pull
DevOps 5
Session 2 (Jenkins Installation)
i. Download:
1. Go to https://adoptium.net/
b. Install:
java -version
a. Go to:
i. https://www.jenkins.io/download/
DevOps 6
3. Step 3: Install Jenkins
DevOps 7
ii. Default installation path: C:\Program Files\Jenkins
DevOps 8
iii. Default port: 8080
DevOps 9
b. When prompted:
DevOps 10
4. Step 4: Unlock Jenkins for First Use
d. Go to:
C:\Program Files\Jenkins\secrets\initialAdminPassword
e. Copy the password from that file and paste it into the browser.
DevOps 11
5. Step 5: Install Suggested Plugins
b. Jenkins will install essential plugins like Git, Build tools, etc.
DevOps 12
6. Step 6: Create First Admin User
i. Username
ii. Password
iv. Email
DevOps 13
8. Verify Jenkins Service
e. 🚀 Jenkins is Installed!
f. You can now access it via:
http://localhost:8080
DevOps 14
b. Open browser → go to: http://localhost:8080
c. Select “Pipeline”.
d. Click OK.
pipeline {
agent any
DevOps 15
stages {
stage('Build') {
steps {
echo 'Building the project...'
}
}
stage('Test') {
steps {
echo 'Running tests...'
}
}
stage('Deploy') {
steps {
echo 'Deploying application...'
}
}
}
}
a. Click Save.
DevOps 16
Session 4 (Setting Up a Simple Python Application with
Docker)
1. Prerequisites
wsl --install
C:\> cd C:\Users\varal\Downloads
C:\Users\varal\Downloads> start /w "" "Docker Desktop Installer.exe"
ii. Explanation:
DevOps 17
c. -installation-dir=D:\Docker: Specifies the custom installation
directory ( D:\Docker in this case). Docker will be installed in this
directory instead of the default path.
mkdir my-python-app
cd my-python-app
print("Hello, Docker!")
c. Create a Dockerfile
i. In the same directory, create a Dockerfile . This file will define the
instructions for building your Docker image.
FROM python:3.8-slim
WORKDIR /app
COPY . /app
CMD ["python", "app.py"]
ii. Explanation:
3. COPY . /app: Copy the current directory contents into the /app
DevOps 18
d. Build the Docker Image
i. With your Dockerfile and app.py in place, build the Docker image using
the following command:
iv. The build process will take some time. Once completed, the image my-
i. Create and start a Docker container from your newly built image:
ii. This command will execute the app.py script inside the container, and
you should see the output:
Hello, Docker!
DevOps 19
f. Start the container in the foreground (you can see the logs directly):
ii. This will attach to the container’s output and you’ll be able to see the
logs. If the app finishes executing, the container will stop.
docker rm my-python-container
DevOps 20
i. Restart the Container (Optional)
images.zip
ii. html-image/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-s
cale=1.0">
<title>HTML Container</title>
</head>
<body>
<h1>Hello from the HTML container!</h1>
DevOps 21
</body>
</html>
iii. html-image/Dockerfile
FROM nginx:latest
WORKDIR /usr/share/nginx/html
COPY index.html /usr/share/nginx/html/
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
b. Java Service
ii. java-image/Student.java
iii. java-image/Dockerfile
FROM openjdk:latest
WORKDIR /app
COPY . /app
RUN javac Student.java
CMD ["java", "Student"]
ii. js-image/index.js
DevOps 22
console.log("Node.js container running: I am a student");
iii. js-image/Dockerfile
FROM node:latest
WORKDIR /app
COPY . /app
CMD ["node", "index.js"]
d. Python Service
ii. py-image/app.py
import os
print("Python container running: This is my first image.")
print("Current Directory:", os.getcwd())
iii. py-image/Dockerfile
FROM python:3.8-slim
WORKDIR /app
COPY . /app
CMD ["python", "app.py"]
b. docker-compose.yml
version: '3.8'
services:
DevOps 23
java-app:
build: ./java-image
container_name: java-container
command: ["java", "Student"]
python-app:
build: ./py-image
container_name: python-container
command: ["python", "app.py"]
js-app:
build: ./js-image
container_name: js-container
command: ["node", "index.js"]
html-app:
build: ./html-image
container_name: html-container
ports:
- "8081:80"
cd /path/to/practical-05
DevOps 24
docker compose build
c. or
d. This will build all images and start the containers in the background.
docker ps -a
b. Output:
DevOps 25
5. Viewing Logs
b. Output:
DevOps 26
c. For HTML, open in a browser: http://localhost:8081/
DevOps 27
6. Stopping and Removing Containers
DevOps 28
b. To remove all images (optional):
7. Restarting Containers
docker compose up -d
DevOps 29
9. Commands
Command Purpose
docker compose build Build all images
docker compose up -d Start containers in detached mode
docker ps List running containers
docker logs <container_name> View logs of a container
docker compose down Stop and remove containers
docker compose restart <service_name> Restart a specific service
docker compose down --rmi all --volumes Remove containers, images, and volumes
i. Run:
wsl --install
DevOps 30
c. You will be asked to create a username and password.
c. Install Ansible:
DevOps 31
5. Step 5: Verify Installation
a. Command
ansible --version
[web]
192.168.1.10
[db]
192.168.1.20
DevOps 32
Session 7 (Kubernetes Setup on Windows 11
(Minikube + Docker))
a. Enable Virtualization
i. Download: https://www.docker.com/products/docker-desktop
wsl --install
e. Install Minikube
a. Command
DevOps 33
kubectl get nodes
b. Expected output:
a. Command
minikube dashboard
mkdir grafana-prometheus
cd grafana-prometheus
a. prometheus.yml
global:
scrape_interval: 15s
scrape_configs:
DevOps 34
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
version: '3.7'
services:
prometheus:
image: prom/prometheus
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
grafana:
image: grafana/grafana
ports:
- "3000:3000"
volumes:
- grafana-storage:/var/lib/grafana
volumes:
grafana-storage:
docker compose up -d
DevOps 35
b. Prometheus UI: http://localhost:9090
a. Login to Grafana.
c. Choose Prometheus.
DevOps 36