Skip to content
Mani Karthik Gurram edited this page Apr 11, 2025 · 2 revisions

Beginner-Friendly DevOps Project Explanation

a6480ced-b8d6-4cf7-a051-7392d25289b5

Goal:

To build a simple web app, deploy it in the cloud, and monitor it in real-time using DevOps tools.

Step 1: Build a Simple Web App

We started with a Python Flask app that shows a simple message like "Hello from DevOps!".

Why Flask?

  1. It's a lightweight Python web framework β€” perfect for beginners.
  2. Easy to write and test.
  3. Simple to extend with monitoring tools.

🐳Step 2: Containerize the App with Docker

Instead of running the app manually, we wrapped it into a Docker container.

Why Docker?

  • Makes the app portable: β€œRuns the same anywhere.”
  • Simplifies deployment (no need to install Python, Flask, etc., on each server).
  • Easy to manage multiple apps as containers.

We wrote a Dockerfile to: Use a Python base image. Install Flask and monitoring tools.

Start the app automatically when the container runs.

πŸ”­ Step 3: Expose Metrics for Monitoring

We wanted to track app usage β€” like how many times it’s visited.

πŸ“Œ How? We added a special URL /metrics using prometheus_flask_exporter.

πŸ“Œ Why /metrics?

  1. It gives live information like:
  • How many requests your app received
  • What type (GET/POST)
  • What status codes (200/404/etc.)
  1. These are machine-readable numbers, perfect for monitoring.

Step 4: Deploy Everything on an Azure VM

We needed a server to host our app, so we used an Azure Virtual Machine (VM).

πŸ“Œ Why Azure VM?

  • It’s like a computer in the cloud.
  • You control it like your own system.
  • Easy to install Docker and run multiple containers.

πŸ“ˆ Step 5: Add Prometheus to Collect Metrics

We used Prometheus to collect data from the app automatically.

πŸ“Œ Why Prometheus?

  • It pulls data from /metrics every few seconds.
  • Stores all the data in a time-series database.
  • Helps us track performance over time.

πŸ› οΈ We configured prometheus.yml to tell Prometheus:

β€œHey, go check on this container called webapp every 15 seconds at port 5000.”

πŸ“Š Step 6: Visualize the Data with Grafana

Seeing numbers is fine… but visual dashboards make it easier!

πŸ“Œ Why Grafana?

  • Turns raw metrics into charts and graphs.
  • Helps identify issues quickly.
  • Lets you customize dashboards for your app.

πŸ› οΈ We connected Grafana to Prometheus and built a dashboard showing:

  • Request rates
  • Errors (if any)
  • Traffic over time

πŸ” Step 7: Automate with GitHub Actions (CI/CD)

Manually deploying containers every time is tiring. πŸ“Œ Why GitHub Actions?

  • It automates the process when you push code to GitHub.
  • It builds the Docker image, pushes it to Docker Hub, and deploys it to the Azure VM via SSH.

πŸ” We used GitHub Secrets to keep:

  • Docker credentials
  • SSH key to login to the Azure VM

πŸ”— Step 8: Connect Everything with Docker Network

Prometheus couldn’t β€œtalk” to Flask app until we connected both to a custom Docker network (devops-net).

πŸ“Œ Why Docker Network? Allows containers to communicate using their names. For example, Prometheus can reach webapp:5000 because they’re on the same network.

βœ… Final Result:

You have a working system where:

  • A Flask app is deployed in Docker on Azure.
  • Prometheus collects its metrics.
  • Grafana visualizes them.
  • GitHub Actions automates deployment when code is updated.