Ravindra BagaleCourses & study guides मराठी

How to Read This Course

DevOps

0.3 Course map (where you are going)

Why: the problem

When students see a list of 70 chapters, they feel lost. Git, Docker, Jenkins, Terraform, Kubernetes, Prometheus. It looks like 20 separate subjects. It is not. In a real company like Zomato, all these tools work on one thing: the code a developer just wrote. Git saves the change. A CI tool such as GitHub Actions or Jenkins tests it. Docker packs it into an image. Terraform creates the servers. Kubernetes runs many copies. Prometheus and Grafana watch it. Each tool is one station on the same road. In this lesson you will walk that road once, in small, with one tiny app. You will not master any tool today. You will just see where each chapter fits, so when you reach it later you already know why it exists.

What we will build

You will take a 10-line Python web app called menu and push it through the main stations of the course: save it in Git, test it, put it in a Docker image, run it with Docker Compose, and write the CI workflow and Kubernetes file that later chapters explain in depth. Each station is one folder and one command.

What: every term in plain English

  • Station — One step on the road from code to users. Each station has its own chapter.
  • Source control — Saving every change with Git, so you can see and undo changes.
  • CI — Continuous Integration. Every change is built and tested automatically.
  • CD — Continuous Delivery or Deployment. Tested changes are shipped automatically.
  • Image — A packed app made by Docker. It runs the same everywhere.
  • Infrastructure as Code — Servers and networks written as files (Terraform), not clicked in a console.
  • Orchestration — Running and healing many containers on many servers (Kubernetes).
  • Monitoring — Watching numbers like errors and CPU, and alerting a person when they go bad.
Make the project folder Write the app Station 1, Git: save it Station 2, Test: check it Station 3, Docker: pack it Station 4, Check it like a user See the whole map
The road from code to users: one station per chapter

How: step by step

  1. Make the project folder

    mkdir -p ~/devops-lab/menu && cd ~/devops-lab/menu && git init -q && pwd
    

    What it does: Creates the folder for the whole walk and starts Git in it.

    Output

    /home/ravi/devops-lab/menu
    
  2. Write the app

    printf 'from flask import Flask\napp = Flask(__name__)\n@app.get("/")\ndef home():\n    return "Paneer tikka, Dal makhani"\n' > app.py
    cat app.py
    

    What it does: A tiny Flask web app that returns a menu.

    Output

    from flask import Flask
    app = Flask(__name__)
    @app.get("/")
    def home():
        return "Paneer tikka, Dal makhani"
    
  3. Station 1, Git: save it

    git add app.py && git commit -qm "menu app" && git log --oneline
    

    What it does: Saves the first version. Chapters 2 and 3 cover Git.

    Output

    4e1d2c7 menu app
    
  4. Station 2, Test: check it

    python3 -m venv .venv && . .venv/bin/activate && pip install -q flask pytest && pytest -q
    

    What it does: Creates a private Python space, installs Flask and pytest, runs tests. Chapter 8 covers CI.

    Output

    1 passed in 0.12s
    
  5. Station 3, Docker: pack it

    docker build -t menu:1 . && docker run -d --name menu -p 5000:5000 menu:1
    

    What it does: Packs the app into an image and runs it. Chapters 47 to 58 cover Docker.

    Output

    => naming to docker.io/library/menu:1
    9c2e4f...
    
  6. Station 4, Check it like a user

    curl -s localhost:5000
    

    What it does: Calls the app the way a browser would.

    Output

    Paneer tikka, Dal makhani
    
  7. See the whole map

    ls -1
    

    What it does: Each file belongs to one station and one part of the course.

    Output

    Dockerfile
    app.py
    compose.yaml
    k8s.yaml
    test_app.py
    .ci.yml
    

Example 1: The app, its test and its Dockerfile

Stack. Python 3.12, Flask 3.0, pytest 8

Goal. The app, its test and its Dockerfile. Stations 1 to 3.

test_app.py

from app import app

def test_home():
    r = app.test_client().get("/")
    assert r.status_code == 200
    assert b"Paneer" in r.data

Dockerfile

FROM python:3.12-slim
WORKDIR /app
RUN pip install --no-cache-dir flask==3.0.3
COPY app.py .
EXPOSE 5000
CMD ["flask", "--app", "app", "run", "--host=0.0.0.0", "--port=5000"]

What each line does

  • app.test_client() — A fake browser that Flask gives for tests.
  • assert r.status_code == 200 — The page must load.
  • assert b"Paneer" in r.data — The page must show the menu.
  • FROM python:3.12-slim — A small official Python image.
  • RUN pip install flask==3.0.3 — Installs a pinned Flask version.
  • --host=0.0.0.0 — Listen on all addresses so traffic from outside the container reaches the app.

Green output

$ pytest -q
.                                                    [100%]
1 passed in 0.12s
$ docker build -t menu:1 .
 => naming to docker.io/library/menu:1

Expected result. The test passes and the image builds. These two checks are what a CI tool will run for you on every change.

Example 2: Run the app with Docker Compose

Stack. Docker Compose v2

Goal. Run the app with Docker Compose. A preview of chapter 53.

compose.yaml

services:
  menu:
    build: .
    ports:
      - "5000:5000"
    restart: unless-stopped

terminal

docker rm -f menu
docker compose up -d --build
docker compose ps
curl -s localhost:5000

What each line does

  • services: menu — One service named menu.
  • build: . — Build the image from the Dockerfile in this folder.
  • ports 5000:5000 — Laptop port 5000 to container port 5000.
  • restart: unless-stopped — Restart it if it crashes, unless you stopped it yourself.
  • docker compose up -d --build — Build and start in the background.

Green output

[+] Running 2/2
 ✔ Network menu_default   Created
 ✔ Container menu-menu-1  Started
NAME          IMAGE       STATUS
menu-menu-1   menu-menu   Up 3 seconds
Paneer tikka, Dal makhani

Expected result. One file now describes how to run the app. Later you will add a database in the same file.

Example 3: The CI file and the Kubernetes file, written now and explained later

Stack. GitHub Actions syntax, Kubernetes 1.30

Goal. The CI file and the Kubernetes file, written now and explained later.

.ci.yml (GitHub Actions style, chapter 9)

name: ci
on: [push]
jobs:
  test-and-build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: pip install flask==3.0.3 pytest
      - run: pytest -q
      - run: docker build -t menu:${{ github.sha }} .

k8s.yaml (Kubernetes, chapters 15 and 18)

apiVersion: apps/v1
kind: Deployment
metadata:
  name: menu
spec:
  replicas: 3
  selector:
    matchLabels: {app: menu}
  template:
    metadata:
      labels: {app: menu}
    spec:
      containers:
      - name: menu
        image: menu:1
        ports:
        - containerPort: 5000

What each line does

  • on: [push] — Run the pipeline on every push.
  • uses: actions/checkout@v4 — Download the code into the CI machine.
  • run: pytest -q — The same test you ran by hand.
  • menu:${{ github.sha }} — Tag the image with the commit ID, so every image is traceable.
  • kind: Deployment — Ask Kubernetes to keep copies running.
  • replicas: 3 — Three copies, healed automatically.

Green output

$ git add . && git commit -qm "ci and k8s files"
$ git log --oneline
7a9b0c1 ci and k8s files
4e1d2c7 menu app

Expected result. You now hold the whole map in one folder. Every chapter of the course explains one of these files in depth.

Verify: did it work?

  1. Check the app answers

    curl -s -o /dev/null -w "%{http_code}\n" localhost:5000
    

    What it does: Prints only the HTTP status code.

    Output

    200
    
  2. Check Git has every file

    git ls-files
    

    What it does: Lists the files Git is tracking.

    Output

    .ci.yml
    Dockerfile
    app.py
    compose.yaml
    k8s.yaml
    test_app.py
    

When it is red 1

ModuleNotFoundError: No module named 'flask'

Cause. Flask is not installed in the Python you are using.

Fix, step by step

  1. Activate the venv: . .venv/bin/activate.
  2. Run pip install flask pytest.
  3. Run pytest -q again.

When it is red 2

Bind for 0.0.0.0:5000 failed: port is already allocated

Cause. The old menu container still uses port 5000.

Fix, step by step

  1. Run docker ps to find it.
  2. Run docker rm -f menu.
  3. Run docker compose up -d again.

When it is red 3

curl: (56) Recv failure: Connection reset by peer

Cause. Flask is listening only inside the container on 127.0.0.1.

Fix, step by step

  1. Check the Dockerfile CMD has --host=0.0.0.0.
  2. Rebuild with docker compose up -d --build.
  3. Run curl again.

Cleanup

  1. Stop Compose

    docker compose down
    

    What it does: Stops and removes the container and network.

    Output

    [+] Running 2/2
     ✔ Container menu-menu-1  Removed
     ✔ Network menu_default   Removed
    
  2. Keep the folder

    ls ~/devops-lab/menu
    

    What it does: Keep this project. Later chapters reuse it.

    Output

    Dockerfile  app.py  compose.yaml  k8s.yaml  test_app.py
    

Ravindra Bagale's Tip

Keep this map in mind. Whenever you read a chapter, ask yourself: which station am I at right now? Then you will not get confused.

Practice tasks

Easy Add a station

Why: You will add monitoring later; plan it now.

What to do: Write one line in notes.md: which number would you watch for this app?

How:
  1. Think of errors, response time, CPU.

Check: You picked one number and said why.

Medium Break the test

Why: CI is only useful if a broken change fails.

What to do: Change the return text so "Paneer" is missing and run pytest.

How:
  1. Edit app.py.
  2. pytest -q

Check: pytest shows 1 failed with an assert error.

Hard Add a health page

Why: Kubernetes and load balancers check health pages.

What to do: Add a /health route that returns ok and test it.

How:
  1. Add @app.get("/health").
  2. Add a test.
  3. curl localhost:5000/health

Check: curl prints ok and the test passes.

Easy Say Course map in two lines

Why: If you can say it simply, you understand it. Interviewers want the short version first.

What to do: Write two short lines about Course map for a friend who is new to IT.

How:
  1. Write what problem it solves.
  2. Write one command or file you used for it.
  3. Read it aloud.

Check: Your friend understands it without asking a question.

Easy Run the commands again from memory

Why: Typing from memory makes the commands stick. Copy-paste does not.

What to do: Close this page and run the main steps of this lesson again.

How:
  1. Open a fresh terminal.
  2. Type each command yourself.
  3. Open the page only when stuck.

Check: You got the same green output without copying.

Medium Break it on purpose

Why: You must know the red message by face. In a real job there is no time to read slowly.

What to do: Cause one error from the "When it is red" part of this lesson and fix it.

How:
  1. Follow one error section.
  2. Copy the exact message into your notes.
  3. Write the fix in one line.

Check: You fixed it using only your notes.

Medium Write a one-page note

Why: A short note in your own words is the best revision.

What to do: Write a note page for this lesson in ~/devops-lab/notes.md.

How:
  1. Title, why, the commands, one error and its fix.

Check: A classmate can follow your note alone.

Hard Explain it like an interview

Why: Interviewers want real stories, not definitions.

What to do: Record a 60 second answer about this lesson on your phone.

How:
  1. Say the problem, what you did, the command you ran, and one error you hit.

Check: Your answer has a real command and a real error message.

Hard Draw the flow top to bottom

Why: A drawing shows the order of things.

What to do: Draw this lesson as boxes from top to bottom on paper.

How:
  1. One box per step.
  2. Write the command next to each box.

Check: Each box matches a step you really ran.

Easy Teach it to someone

Why: Teaching shows the gaps in your own understanding.

What to do: Explain this lesson to a friend or family member in five minutes.

How:
  1. Use one real app as the example (Swiggy, Netflix, Paytm).

Check: They can tell you back the main idea.

Homework: try at home

Try at home

At home, change the menu text to add one dish. Run the test, rebuild with Compose and commit. Then draw the stations on paper: Git, test, Docker, CI, Kubernetes, monitoring, and write the chapter numbers next to each one.

Recap

  • All DevOps tools work on the same code, one station each.
  • Git saves, CI tests, Docker packs, Terraform builds servers, Kubernetes runs, monitoring watches.
  • One small app can walk the whole road.
  • Keep ~/devops-lab/menu; later chapters reuse it.
  • When lost in a chapter, ask: which station is this?

FAQ

Do I need to learn the tools in this order?

Mostly yes. Git and Linux first, then Docker, then CI/CD, then Kubernetes and Terraform.

Is Jenkins or GitHub Actions better to learn first?

Learn the idea of CI first. GitHub Actions is easier to start; many companies still use Jenkins, so you will learn both.

Why Flask and not Java?

It is short and easy to read. Later chapters show Java, Node.js, Go and .NET too.

Will I need Kubernetes for every job?

Not every job, but most DevOps job posts ask for it.

Where does AWS fit in this map?

AWS provides the servers, registry, databases and load balancers that these tools use.

Interview questions

  1. Explain a CI/CD pipeline end to end.

    A developer pushes to Git, CI builds and tests, an image is built and pushed to a registry, CD deploys it to Kubernetes or servers, and monitoring watches it.

  2. What is the difference between CI and CD?

    CI builds and tests every change. CD ships tested changes to an environment, automatically or after approval.

  3. Why tag images with a commit SHA instead of latest?

    It is traceable and makes rollbacks exact.

  4. Where does Terraform fit?

    It creates the infrastructure (VPC, servers, clusters) that the app runs on.

  5. What should you monitor first for a web app?

    Error rate, latency, traffic and saturation (the four golden signals).

Quick quiz

Q1. Which tool saves every change of your code?

Git.

Q2. What does CI do on every push?

Builds and tests the code automatically.

Q3. Which file tells Kubernetes to keep 3 copies?

The Deployment YAML (k8s.yaml).

Q4. Why does Flask need --host=0.0.0.0 in a container?

So traffic from outside the container can reach it.

Q5. Why tag images with the commit ID?

So you know exactly which code is inside each image.

Did you understand? Let us try it once more.