DevOps
Index
Sr. No. Date Program List Pg. No Sign
Git and GitHub
practical
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
Install & Set Up
Ansible on
7 25-03-2025
Windows (via
WSL)
Kubernetes Setup
on Windows 11
8 12-04-2025
(Minikube +
Docker)
Grafana +
Prometheus
Setup on
9 24-04-2025
Windows 11
(Locally with
Docker)
Session 1 (Git and GitHub practical)
1. Prerequisites:
a. Install Git on your local machine: Download Git
b. Create a GitHub account: GitHub Signup
2. Step 1: Create a Repository on GitHub
a. Log in to your GitHub account.
b. Click on the "+" icon at the top right corner and select "New repository".
c. Fill in the repository details:
i. Repository Name: (e.g., my-project )
ii. Description: (optional)
iii. Public/Private: (choose based on your preference)
DevOps 2
iv. Initialize with a README: (uncheck this if you want to create locally)
d. Click "Create repository".
3. Step 2: Initialize Git in Your Local Project
a. Open a terminal (command line) in your project directory:
cd /path/to/your/project
b. Initialize the Git repository:
This command creates a hidden
.git directory that contains all the necessary metadata for the repository.
git init
4. Step 3: Add Remote Repository
a. Copy the URL of your GitHub repository (from the "Quick setup" page
after creating the repository on GitHub).
b. Add the remote repository URL:
Replace
yourusernameand my-project with your GitHub username and repository name,
respectively.
git remote add origin <https://github.com/yourusername/my-project.gi
t>
5. Step 4: Commit and Push Initial Project Files
a. Stage all files for the first commit:
git add .
The . tells Git to add all files in the current directory.
b. Commit the files:
DevOps 3
git commit -m "Initial commit"
The -m flag allows you to add a commit message.
c. Push the commit to GitHub:
git push -u origin master
The -u flag sets the upstream for the master branch, meaning future git
push commands will know where to push by default.
d. You could encounter the problem of setting your identity first before
uploading the code to your remote repository; the solution is
git config --global user.name "Your Github Name (Not UserName)"
git config --global user.email "Your Github email address"
e. Push the commit to GitHub:
git push -u origin master
The -u flag sets the upstream for the master branch, meaning future git
push commands will know where to push by default.
6. Step 5: Making Changes and Pushing Updates
Whenever you make changes to your code, follow these steps:
a. Check the status of your repository:
git status
This will show you which files have changed.
b. Stage the changed files:
git add .
DevOps 4
You can also stage specific files by replacing . with the filenames.
c. Commit the changes:
git commit -m "Describe your changes"
d. Push the changes to GitHub:
git push
7. Additional Useful Commands
a. Check the commit history:
git log
b. Clone an existing repository:
git clone <https://github.com/username/repository.git>
c. Create and switch to a new branch:
git checkout -b new-branch
d. Merge changes from another branch:
git merge branch-name
e. Pull the latest changes from the remote repository:
git pull
DevOps 5
Session 2 (Jenkins Installation)
1. Step 1: Install Java (JDK 11 or 17)
a. Jenkins requires Java to run.
i. Download:
1. Go to https://adoptium.net/
2. Download Temurin JDK 17 (LTS) for Windows (x64).
b. Install:
i. Run the installer and follow prompts.
ii. During installation, check "Set JAVA_HOME environment variable."
c. Verify Java Installation:
i. Open Command Prompt and run:
java -version
ii. You should see something like:
openjdk version "17.0.x"
2. Step 2: Download Jenkins
a. Go to:
i. https://www.jenkins.io/download/
b. Choose "Windows" > Download the .msi installer (Recommended for
beginners).
DevOps 6
3. Step 3: Install Jenkins
a. Run the .msi installer:
i. It will install Jenkins as a Windows Service.
DevOps 7
ii. Default installation path: C:\Program Files\Jenkins
DevOps 8
iii. Default port: 8080
DevOps 9
b. When prompted:
i. Leave the default port as 8080
ii. Select the installed Java path (should auto-detect)
DevOps 10
4. Step 4: Unlock Jenkins for First Use
a. After installation completes:
b. Open your browser and go to: http://localhost:8080
c. You’ll be asked for an unlock key.
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
a. Select "Install suggested plugins"
b. Jenkins will install essential plugins like Git, Build tools, etc.
DevOps 12
6. Step 6: Create First Admin User
a. After plugin installation, you’ll be prompted to create:
i. Username
ii. Password
iii. Full name
iv. Email
7. Step 7: Jenkins Dashboard
a. Once setup is complete, you’ll be taken to the Jenkins Dashboard.
b. You’re now ready to create jobs, configure pipelines, etc.
DevOps 13
8. Verify Jenkins Service
a. You can verify Jenkins is running as a Windows Service:
b. Press Win + R , type services.msc , and press Enter.
c. Look for "Jenkins" in the list.
d. Make sure its status is 'Running' and startup type is 'Automatic'.
e. 🚀 Jenkins is Installed!
f. You can now access it via:
http://localhost:8080
Session 3 (Jenkins Pipeline Creation)
1. Step 1: Start Jenkins
a. Make sure Jenkins is running:
DevOps 14
b. Open browser → go to: http://localhost:8080
2. Step 2: Create a New Pipeline Job
a. On the Jenkins Dashboard, click "New Item".
b. Enter a name (e.g., MyFirstPipeline ).
c. Select “Pipeline”.
d. Click OK.
3. Step 3: Configure the Pipeline
a. You'll be taken to the project configuration page.
b. In the Pipeline section:
c. Definition: Choose Pipeline script (to write inline script)
4. Script: Paste the following example:
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...'
}
}
}
}
5. Step 4: Save and Run the Pipeline
a. Click Save.
b. On the project page, click "Build Now".
6. Step 5: View the Pipeline Output
a. Click on the build number (e.g., #1 ) in the Build History.
b. Click “Console Output” to view logs.
c. Alternatively, go to “Pipeline Steps” to see the graphical stage view.
7. Example Pipeline Output:
Building the project...
Running tests...
Deploying application...
DevOps 16
Session 4 (Setting Up a Simple Python Application with
Docker)
1. Prerequisites
a. Install WSL (Windows Subsystem for Linux):
i. Run the following command to install WSL on your machine:
wsl --install
b. Download Docker Desktop:
i. Download Docker Desktop from the official Docker website.
c. Optional: Install Docker to a custom directory:
i. Open Command Prompt as Administrator and run:
C:\> cd C:\Users\varal\Downloads
C:\Users\varal\Downloads> start /w "" "Docker Desktop Installer.exe"
ii. Explanation:
1. cd C:\Users\varal\Downloads : Navigates to the folder where the Docker
installer is located.
2. start /w "" "Docker Desktop Installer.exe" install -accept-license --installation-
dir=D:\Docker : Runs the Docker installer with the following options:
a. install : Initiates the installation process.
b. accept-license : Automatically accepts Docker's End User License
Agreement.
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.
2. Step-by-Step Docker Setup
a. Create a Project Directory
i. Begin by creating and navigating to the project directory:
mkdir my-python-app
cd my-python-app
b. Create a Python Application ( app.py )
i. Inside the my-python-app directory, create a Python script ( app.py ). Here's
a simple example:
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:
1. FROM python:3.8-slim: Base image with Python 3.8.
2. WORKDIR /app: Set the working directory inside the container.
3. COPY . /app: Copy the current directory contents into the /app
directory in the container.
4. CMD ["python", "app.py"]: Command to run the Python script
when the container starts.
DevOps 18
d. Build the Docker Image
i. With your Dockerfile and app.py in place, build the Docker image using
the following command:
docker build -t my-python-image .
ii. t my-python-image : Tags the image with the name my-python-image .
iii. . : The period refers to the current directory.
iv. The build process will take some time. Once completed, the image my-
python-image will be available locally.
e. Run the Docker Container
i. Create and start a Docker container from your newly built image:
docker run --name my-python-container my-python-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):
i. Start the container with logs too.
docker start -a my-python-container
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.
g. Stopping the Container (Optional)
i. To stop the container after running:
docker stop my-python-container
h. Remove the Container (Optional)
i. If you wish to remove the stopped container:
docker rm my-python-container
DevOps 20
i. Restart the Container (Optional)
i. To restart the container and view the output again:
docker restart my-python-container
Session 5 (Docker Compose: Multi-Container)
images.zip
1. Setting Up Each Image
a. HTML Service (Nginx)
i. Create html-image/ directory and add the following files:
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
i. Create java-image/ directory and add:
ii. java-image/Student.java
public class Student {
public static void main(String[] args) {
System.out.println("Java container running: I am a student");
}
}
iii. java-image/Dockerfile
FROM openjdk:latest
WORKDIR /app
COPY . /app
RUN javac Student.java
CMD ["java", "Student"]
c. JavaScript (Node.js) Service
i. Create js-image/ directory and add:
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
i. Create py-image/ directory and add:
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"]
2. Docker Compose Configuration
a. Now, create docker-compose.yml in the project root:
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"
c. What This Does:
i. Builds four services ( java-app , python-app , js-app , html-app ).
ii. No need to manually build images—Docker Compose handles it.
iii. The HTML container is exposed on localhost:8081 .
3. Steps to Build and Run Containers
a. Navigate to Project Directory
cd /path/to/practical-05
b. Build All Images
DevOps 24
docker compose build
c. or
docker compose up --build -d
d. This will build all images and start the containers in the background.
4. Verifying Running Containers
a. Check if all containers are running:
docker ps -a
b. Output:
DevOps 25
5. Viewing Logs
a. For each container:
docker logs java-container
docker logs python-container
docker logs js-container
b. Output:
DevOps 26
c. For HTML, open in a browser: http://localhost:8081/
DevOps 27
6. Stopping and Removing Containers
a. To stop all running containers:
docker compose down
DevOps 28
b. To remove all images (optional):
docker rmi java-image python-image js-image html-image
7. Restarting Containers
a. After stopping, restart with:
docker compose up -d
b. To restart a specific service (e.g., Python):
docker compose restart python-app
8. Removing Everything (Full Cleanup)
a. If you want to remove containers, images, and volumes:
docker compose down --rmi all --volumes
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
Session 6 (Install & Set Up Ansible on Windows (via
WSL))
1. Step 1: Enable WSL on Windows
a. Open PowerShell as Administrator
i. Run:
wsl --install
b. This installs WSL 2 and Ubuntu (default distro)
c. Restart your computer if prompted.
2. Step 2: Launch Ubuntu (Linux Terminal)
a. After reboot, open "Ubuntu" from Start Menu.
b. Let it set up.
DevOps 30
c. You will be asked to create a username and password.
3. Step 3: Update Ubuntu
a. In the Ubuntu terminal:
sudo apt update && sudo apt upgrade -y
4. Step 4: Install Ansible
a. Install required dependencies:
sudo apt install software-properties-common -y
b. Add Ansible PPA:
sudo add-apt-repository --yes --update ppa:ansible/ansible
c. Install Ansible:
sudo apt install ansible -y
DevOps 31
5. Step 5: Verify Installation
a. Command
ansible --version
b. You should see the installed version like:
ansible [core 2.15.x]
6. Step 6: Set Up Ansible Inventory (Hosts File)
a. Edit the inventory file:
sudo nano /etc/ansible/hosts
b. Add remote servers (example):
[web]
192.168.1.10
[db]
192.168.1.20
7. Step 7: Test Connection to Remote Machine
a. Ensure the remote Linux machine has SSH enabled.
b. On Ubuntu, test connection:
ansible all -m ping -u ubuntu --ask-pass
DevOps 32
Session 7 (Kubernetes Setup on Windows 11
(Minikube + Docker))
1. Step 1: Install Prerequisites
a. Enable Virtualization
i. Make sure virtualization is enabled in BIOS.
b. Install Docker Desktop
i. Download: https://www.docker.com/products/docker-desktop
ii. Install it and ensure WSL 2 is enabled in Docker Settings.
c. Install WSL (if not already)
wsl --install
d. Install kubectl (Kubernetes CLI)
choco install kubernetes-cli
e. Install Minikube
choco install minikube
f. (Install Chocolatey first if not installed)
2. Step 2: Start Minikube with Docker Driver
a. In PowerShell or Command Prompt:
minikube start --driver=docker
b. This launches a local Kubernetes cluster using Docker as the VM driver.
3. Step 3: Verify Kubernetes Is Running
a. Command
DevOps 33
kubectl get nodes
b. Expected output:
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane Xs vX.X.X
4. Step 4: Access Kubernetes Dashboard (optional)
a. Command
minikube dashboard
b. This opens a browser with the Kubernetes Dashboard.
Session 8 (Grafana + Prometheus Setup on Windows
11 (Locally with Docker))
1. Step 1: Create a Project Directory
mkdir grafana-prometheus
cd grafana-prometheus
2. Step 2: Create Configuration Files
a. prometheus.yml
global:
scrape_interval: 15s
scrape_configs:
DevOps 34
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
3. Step 3: Create docker-compose.yml
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:
4. Step 4: Start Services
a. In the same directory:
docker compose up -d
5. Step 5: Access Grafana & Prometheus
a. Grafana UI: http://localhost:3000
a. Username: admin , Password: admin
DevOps 35
b. Prometheus UI: http://localhost:9090
6. Step 6: Connect Prometheus as Grafana Data Source
a. Login to Grafana.
b. Go to Settings → Data Sources → Add data source.
c. Choose Prometheus.
d. Set URL: http://prometheus:9090
DevOps 36