What is DevOps?
The philosophy that bridges development and operations teams
The Core Idea
DevOps = Development + Operations. Traditionally, developers wrote code and "threw it over the wall" to operations teams who deployed it. This caused slow releases, blame games, and broken production systems.
DevOps is a culture, set of practices, and tools that breaks down these silos. The goal: ship software faster, more reliably, and with fewer failures.
The DevOps Infinity Loop
Key Principles
🤝 Collaboration
Dev and Ops teams share responsibility for the entire software lifecycle
⚡ Automation
Automate testing, builds, deployments to remove human error and go faster
📊 Continuous Feedback
Monitor production constantly; feed insights back to developers immediately
🔄 Continuous Improvement
Small, frequent releases instead of large, risky deployments every 6 months
Popular DevOps Tools
Each phase of DevOps has dedicated tools:
DevOps vs SDLC
Understanding the relationship — DevOps is not a replacement for SDLC
Side-by-Side Comparison
| Aspect | SDLC | DevOps |
|---|---|---|
| Definition | A structured process to plan, create, test, and deliver software | A culture + practice that applies automation and collaboration to SDLC |
| Focus | Phases and deliverables | Speed, quality, and continuous delivery |
| Teams | Dev and Ops work separately | Dev and Ops work together |
| Release Cycle | Long cycles (months) | Short cycles (days/hours) |
| Feedback | After testing phase | Continuous, real-time monitoring |
| Testing | Dedicated test phase | Testing integrated throughout (CI) |
| Deployment | Manual, infrequent | Automated, frequent (CD) |
Key Insight
SDLC Phases (Traditional)
DevOps Enhances Each Phase
Plan → Jira / GitHub Issues
Track tasks, sprints, and user stories collaboratively
Code → Git, GitHub, GitLab
Version control, code reviews, branching strategies
Test → Jenkins, Selenium
Automated unit, integration, regression tests on every commit
Deploy → Docker, Kubernetes
Containerized, automated, repeatable deployments
DevOps Life Cycle
8 phases that run continuously in a loop — never stopping
The 8 Phases
1. 📋 Plan
Define features, set sprint goals. Tools: Jira, Confluence, Trello. Teams align on what to build.
2. 💻 Code
Developers write code in feature branches. Code reviews happen before merging. Tools: Git, VS Code.
3. 🔨 Build
Source code is compiled/bundled into a runnable artifact. Tools: Maven, Gradle, npm, Docker.
4. 🧪 Test
Automated tests run: unit tests, integration tests, security scans. Tools: JUnit, Selenium, SonarQube.
5. 📦 Release
Tested artifact is tagged and prepared for deployment. This may include approval gates.
6. 🚀 Deploy
Release pushed to staging then production. Tools: Kubernetes, Ansible, Terraform, Jenkins.
7. ⚙️ Operate
System runs in production. Ops team manages infrastructure, scaling, and uptime.
8. 📊 Monitor
Track performance, errors, user behavior. Tools: Prometheus, Grafana, ELK Stack, Datadog.
Why "Continuous"?
Real Example: Feature Shipping Timeline
| Traditional | DevOps |
|---|---|
| Plan: 2 weeks | Plan: 2 days (rolling) |
| Code: 3 months | Code: 1–2 week sprints |
| Test: 1 month | Test: Automated, runs in minutes |
| Deploy: Once every 6 months | Deploy: Multiple times per day |
| Total: ~6 months | Total: 1–2 weeks per feature |
Version Control & Basic Git Commands
Git is the foundation of all modern DevOps workflows
What is Version Control?
Version control tracks every change to your code. Think of it like Google Docs "version history" but for entire projects. You can: see who changed what, revert to any past state, work on features in parallel (branching), and merge everyone's work safely.
Essential Git Commands
Git Branching Strategy (GitFlow)
Merge Conflicts
SDLC & DevOps — In Which Scenario?
When to use SDLC models, when DevOps applies, and how they overlap
When to Use Which?
| Scenario | Best Approach | Why |
|---|---|---|
| Banking system, safety-critical software | Waterfall + strict SDLC | Requirements don't change; compliance needed |
| Startup building a product | Agile SDLC + DevOps CI/CD | Rapid iteration, fast feedback from users |
| Large team, multiple services | DevOps + Microservices | Each team deploys independently |
| E-commerce platform | DevOps + Agile | Daily releases, A/B testing, monitoring |
| Government project | Waterfall SDLC | Fixed budget, fixed scope, approval gates |
DevOps in Real Scenarios
🛒 Amazon
Deploys code every 11 seconds. Uses DevOps + microservices. Each team owns their service end-to-end.
🎬 Netflix
Deploys hundreds of times per day. Uses chaos engineering to test resilience in production.
"Move fast and break things" — evolved to "move fast with stable infrastructure" using DevOps.
🏦 Banks
Still use traditional SDLC for core systems but adopt DevOps for customer-facing apps.
What is CI/CD?
Continuous Integration + Continuous Delivery/Deployment — the heart of DevOps
Three Concepts
CI — Continuous Integration
Developers merge code frequently (multiple times a day). Each merge triggers automated builds and tests. Catch bugs early, before they pile up.
CD — Continuous Delivery
Every passing build is automatically prepared for release to staging. A human presses "deploy to production" when ready.
CD — Continuous Deployment
Goes one step further — every passing build is automatically deployed to production with NO human intervention. Used by mature teams with excellent test coverage.
CI/CD Pipeline Stages
git push
compile
JUnit
SonarQube
Docker image
auto
auto/manual
Jenkinsfile — Pipeline as Code
Poll SCM in Jenkins
How Jenkins watches your Git repository for changes
What is Poll SCM?
Poll SCM is a Jenkins trigger that checks your source code repository (Git/SVN) on a schedule. If new commits are found since the last check, Jenkins automatically starts a build. It's like setting an alarm to "check if anything new happened."
H/5 * * * * means "check every 5 minutes." Jenkins uses cron format for scheduling.Poll SCM vs Webhooks
| Poll SCM | Webhook (Push Trigger) |
|---|---|
| Jenkins asks Git: "Any changes?" every N minutes | Git tells Jenkins: "New commit just happened!" |
| Slight delay (up to N minutes) | Instant trigger |
| Works behind firewalls | Git server needs to reach Jenkins |
| Creates unnecessary API calls | Efficient — only triggers when needed |
| Use when webhooks aren't possible | Preferred for public-facing Jenkins |
Cron Syntax Explained
Second Phase of SDLC
The Requirements / System Analysis phase
What is the Second Phase?
The second phase of SDLC is Requirements Analysis (also called System Analysis). After the initial planning, this phase digs deep into what the system must do. Business analysts, stakeholders, and developers gather, document, and validate requirements.
Activities in This Phase
Feasibility Study
Is the project technically, financially, and legally possible?
Requirement Gathering
Interviews, surveys, workshops with stakeholders to understand needs
SRS Document
Software Requirements Specification — the official document of what must be built
Use Case Diagrams
Visual representation of how users interact with the system
Functional vs Non-Functional Requirements
| Functional | Non-Functional |
|---|---|
| What the system does | How well it does it |
| "User can log in with email/password" | "Login must complete in under 2 seconds" |
| "Admin can delete accounts" | "System must handle 10,000 users simultaneously" |
| "System sends email on order" | "99.9% uptime required" |
What is TDD?
Test-Driven Development — write tests BEFORE writing code
The TDD Cycle: Red → Green → Refactor
Write a failing test
Write min code to pass
Clean up the code
TDD Example in Python
Benefits of TDD
Better Design
Writing tests first forces you to think about API design from the caller's perspective
Safety Net
Existing tests catch regressions when you change code later
Documentation
Tests serve as living documentation showing exactly how code should behave
Confidence
Refactor fearlessly — if tests pass, code works correctly
4th Stage of Scrum
Sprint Review — demonstrating what was built
Scrum Framework Overview
What to build
1-4 weeks
15-min standup
Demo to stakeholders
Improve process
The 4th Stage: Sprint Review
At the end of each sprint, the team demonstrates the working software to stakeholders (product owners, customers, management). This is NOT a status report — it's a live demo of working features.
Who attends?
Scrum team + Product Owner + key stakeholders + possibly customers
Duration
Max 4 hours for a 4-week sprint (1 hour per week of sprint)
What happens?
Team demos completed items, stakeholders give feedback, product backlog is updated
Output
Updated product backlog, insights for next sprint planning, stakeholder alignment
Scrum Roles
| Role | Responsibility |
|---|---|
| Product Owner | Manages product backlog, prioritizes features, represents business |
| Scrum Master | Facilitates process, removes blockers, coaches team on Scrum |
| Development Team | Cross-functional team that designs, builds, and tests the product |
Kubernetes Architecture
The brain and muscles of container orchestration
Two Types of Nodes
🧠 Control Plane (Master Node)
The brain. Makes all decisions: where to run containers, how many replicas, handling failures. Components: API Server, Scheduler, Controller Manager, etcd.
💪 Worker Nodes
The muscles. Actually run your containers. Each worker has: Kubelet (talks to master), Kube-proxy (networking), Container Runtime (Docker/containerd).
Control Plane Components
| Component | Role |
|---|---|
| API Server | Front door to K8s. All commands (kubectl) go through it. REST API. |
| etcd | Distributed key-value store. The "database" of cluster state. Source of truth. |
| Scheduler | Decides WHICH worker node to run a new Pod on based on resources |
| Controller Manager | Watches for desired vs actual state. If 3 replicas needed but only 2 running, it creates one more. |
Key Kubernetes Objects
What is Kubernetes?
Container orchestration platform — the OS for your containers
The Core Problem It Solves
Docker lets you run ONE container. But in production, you might need 100 containers, across 10 servers, with automatic restarts when they crash, load balancing between them, and zero-downtime updates. Managing this manually is impossible. Kubernetes automates all of it.
What Kubernetes Does Automatically
Self-Healing
If a container crashes, K8s restarts it. If a node fails, pods move to healthy nodes.
Auto-Scaling
HPA (Horizontal Pod Autoscaler) adds/removes pods based on CPU/memory usage.
Load Balancing
Distributes traffic across all healthy pods using Services.
Rolling Updates
Update containers with zero downtime — gradually replace old pods with new ones.
Secret Management
Store passwords, API keys, certificates securely as K8s Secrets.
Storage Orchestration
Automatically mount storage from cloud, NFS, or local disks.
Essential kubectl Commands
What is Jenkins?
The most popular open-source CI/CD automation server
Jenkins in Simple Terms
Jenkins is an open-source automation server written in Java. It watches your Git repo, and whenever you push code it automatically builds, tests, and deploys your application. Think of Jenkins as a robot developer that never sleeps — it runs your pipeline 24/7.
Key Features
🔌 1800+ Plugins
Integrates with Git, Docker, Kubernetes, Slack, AWS, SonarQube, and almost every DevOps tool.
📜 Pipeline as Code
Define your entire CI/CD pipeline in a Jenkinsfile stored in your repo — versioned with your code.
🌐 Distributed Builds
Master-agent architecture lets you run builds on multiple machines in parallel.
🆓 Free & Open Source
No licensing cost. Large community, extensive documentation, runs on any OS.
Simple Jenkinsfile
Jenkins Architecture
Master-Agent model for distributed, scalable builds
Master-Agent Architecture
Schedules, UI, config
Linux builds
Windows builds
Docker builds
Master vs Agent Responsibilities
| Jenkins Master | Jenkins Agent |
|---|---|
| Hosts the web UI | Executes the actual build steps |
| Stores configuration & job history | Has the build tools (Maven, Node, Docker) |
| Schedules jobs & triggers | Reports results back to master |
| Manages plugins | Can be any OS / cloud VM / container |
| Should NOT run heavy builds | Scales horizontally — add more as needed |
Agent Configuration in Jenkinsfile
V-Model
Verification & Validation model — testing planned at every development stage
The V-Shape Explained
Left Side vs Right Side
| Left Side (Development) | Right Side (Testing) |
|---|---|
| Requirements Analysis | Acceptance Testing (UAT) |
| System Design | System Testing |
| Architecture Design | Integration Testing |
| Module Design | Unit Testing |
| Coding (bottom of V) | ← connects both sides |
When to Use V-Model
✅ Good For
Safety-critical systems (medical devices, aviation), projects with fixed, well-understood requirements, small-to-medium projects.
❌ Not Good For
Projects with changing requirements, long-running projects, when early prototypes are needed, or when budget/timeline is uncertain.
Waterfall Model
The original sequential SDLC — each phase must complete before the next begins
Sequential Phases
Pros & Cons
| Advantages | Disadvantages |
|---|---|
| Simple, easy to understand and manage | No working software until late in the project |
| Well-documented at every phase | Very expensive to go back and fix requirements |
| Works well for fixed-scope projects | Customer sees product only at the end |
| Clear milestones and deliverables | High risk — bugs found late are costly |
| Good for government/compliance projects | Not suitable for complex or evolving projects |
Real-World Analogy
Agile Model
Iterative, incremental development with continuous customer feedback
Agile vs Waterfall Mindset
| Waterfall | Agile |
|---|---|
| Plan everything upfront | Plan just enough, adapt as you go |
| Deliver once at the end | Deliver working software every 2–4 weeks |
| Customer sees product at the end | Customer involved throughout |
| Change is expensive | Change is welcomed and expected |
| Documentation-heavy | Working software over documentation |
The Agile Manifesto (4 Values)
Individuals & Interactions
Over processes and tools — people matter more than rigid workflows
Working Software
Over comprehensive documentation — ship something that works
Customer Collaboration
Over contract negotiation — involve the customer constantly
Responding to Change
Over following a plan — embrace change even late in development
Agile Sprint Cycle
User stories
Pick stories
2–4 weeks
Demo
Improve
Scrum Model
The most widely used Agile framework — structured sprints with defined roles
Scrum Roles
🧑💼 Product Owner
Owns the product backlog. Prioritizes features by business value. The voice of the customer. Decides WHAT gets built.
🏃 Scrum Master
Servant-leader. Removes blockers, facilitates ceremonies, coaches team on Scrum. NOT a project manager.
👩💻 Development Team
Self-organizing, cross-functional team of 3–9 people. Includes developers, testers, designers. Decides HOW to build. Collectively owns the sprint goal.
Scrum Artifacts
| Artifact | Description |
|---|---|
| Product Backlog | Ordered list of ALL features, bugs, and improvements. Owned by Product Owner. |
| Sprint Backlog | Subset of product backlog items the team commits to in one sprint. |
| Increment | The working, potentially shippable product at the end of each sprint. |
| Definition of Done | Team's agreed checklist: coded + tested + reviewed + deployed to staging = Done. |
Scrum Ceremonies
Sprint Planning
Team selects backlog items for the sprint and breaks them into tasks. Time-boxed: 8 hrs max for 4-week sprint.
Daily Scrum (Standup)
15-minute daily sync. Three questions: What did I do? What will I do? Any blockers?
Sprint Review
Demo working software to stakeholders. Inspect the increment and adapt the backlog.
Sprint Retrospective
Team reflects: What went well? What to improve? Action items for next sprint.
CI/CD Pipeline with Jenkins
End-to-end automated pipeline from code commit to production deployment
Full Pipeline Flow
trigger
clone repo
mvn package
JUnit/Selenium
image push
kubectl apply
Production-Ready Jenkinsfile
Make Use of Kubernetes
Practical patterns — Services, ConfigMaps, HPA, and Namespaces
Kubernetes Service Types
| Type | Use Case | Access |
|---|---|---|
| ClusterIP | Internal communication between pods | Only inside cluster |
| NodePort | Expose app on a static port on each node | External via NodeIP:Port |
| LoadBalancer | Production external access via cloud LB | Public IP from cloud provider |
| Ingress | HTTP routing, SSL termination, path-based routing | Domain-based external access |
HPA — Auto-Scale Based on CPU
ConfigMap & Secret
What is GitLab?
All-in-one DevOps platform — Git hosting + CI/CD + registry + monitoring
GitLab vs GitHub vs Jenkins
| Feature | GitLab | GitHub | Jenkins |
|---|---|---|---|
| Git Hosting | ✅ | ✅ | ❌ |
| Built-in CI/CD | ✅ GitLab CI | ✅ Actions | ✅ (dedicated) |
| Container Registry | ✅ Built-in | ✅ GHCR | ❌ |
| Self-hosted option | ✅ Free | ✅ Enterprise | ✅ Free |
| Issue tracking | ✅ Built-in | ✅ Built-in | ❌ |
| Best for | Full DevOps in one tool | Open source community | Complex pipelines |
GitLab CI Pipeline (.gitlab-ci.yml)
GitLab Key Features
🔒 Built-in Security
SAST, DAST, dependency scanning, secret detection — all built into the CI pipeline.
📦 Package Registry
Host npm, Maven, PyPI, Docker packages privately alongside your code.
🌍 GitLab Pages
Deploy static websites directly from your repo — like GitHub Pages.
🔁 Auto DevOps
Auto-detect language and configure a full CI/CD pipeline with zero configuration.
Version Control Types
Local, Centralized, and Distributed — how code history is stored and shared
Three Types
1. Local VCS
History stored only on your machine. Example: RCS. Simple but no collaboration — if your disk dies, history is gone.
2. Centralized VCS (CVCS)
Single central server holds all history. Examples: SVN, CVS. Everyone checks out from one place. Single point of failure.
3. Distributed VCS (DVCS)
Every developer has a full copy of the entire repository history. Examples: Git, Mercurial. Work offline, no single point of failure, fast branching. This is what Git uses.
CVCS vs DVCS
| Centralized (SVN) | Distributed (Git) |
|---|---|
| One central repo | Every clone IS a full repo |
| Need network to commit | Commit offline, push later |
| Branching is slow/expensive | Branching is instant and cheap |
| Server failure = no work | Any clone can restore the repo |
| Simpler mental model | More powerful, slightly more complex |
Why Git Won
Jenkins Image Commands
Docker commands to run, manage, and configure Jenkins as a container
Run Jenkins in Docker
Jenkins with Docker-in-Docker (DinD)
Useful Jenkins Container Commands
Jenkins Maven Project
Build, test, and package a Java Maven app with Jenkins end-to-end
Maven Project Structure
pom.xml Essentials
Maven Lifecycle Commands
Jenkins Pipeline for Maven
Git & Kubernetes Commands
Quick-reference cheatsheet for daily DevOps work
Git Cheatsheet
Kubernetes Cheatsheet
Flask App — DevOps Deployment
Build, containerize, and deploy a Python Flask app with CI/CD
Minimal Flask App
Dockerfile for Flask
Kubernetes Deployment for Flask
CI/CD Step-by-Step
Complete walkthrough — from zero to a working automated pipeline
Step-by-Step Setup
Step 1 — Install Jenkins
Run Jenkins via Docker or install on a server. Access UI at localhost:8080. Install suggested plugins.
Step 2 — Connect Git Repo
In Jenkins: New Item → Pipeline → configure GitHub repo URL + credentials. Enable webhook or Poll SCM.
Step 3 — Write Jenkinsfile
Add a Jenkinsfile to your repo root. Define stages: Checkout → Build → Test → Docker → Deploy.
Step 4 — Configure Tools
In Jenkins Global Tools: add JDK, Maven, Node.js versions. Jenkins auto-installs them on agents.
Step 5 — Add Credentials
Jenkins → Manage → Credentials: add DockerHub login, K8s kubeconfig, SSH keys securely.
Step 6 — First Build
Push a commit. Jenkins triggers automatically. Watch the pipeline stages turn green one by one.
Complete End-to-End Jenkinsfile
Jenkins & Automated Testing
Integrate unit, integration, and code quality tests into your Jenkins pipeline
Types of Automated Tests in CI
| Test Type | Tool | When in Pipeline | Speed |
|---|---|---|---|
| Unit Tests | JUnit, pytest, Jest | After every commit | Seconds |
| Integration Tests | Testcontainers, REST-assured | After build | Minutes |
| Code Coverage | JaCoCo, Istanbul | With unit tests | Seconds |
| Code Quality | SonarQube, Checkstyle | After tests | Minutes |
| E2E / UI Tests | Selenium, Cypress, Playwright | Staging deploy | Minutes–Hours |
| Security Scan | OWASP, Trivy, Snyk | Before deploy | Minutes |
Jenkins Pipeline with Full Test Suite
Test Pyramid Strategy
Docker Hub & Dockerfile
Build images, push to Docker Hub, and write production-grade Dockerfiles
Docker Hub Workflow
Dockerfile
local image
name:version
to Hub
anywhere
Docker Hub Commands
Production-Grade Dockerfile (Multi-Stage)
Dockerfile Best Practices
Use Multi-Stage Builds
Separate build tools from runtime. Final image contains only what's needed — 10x smaller.
Non-Root User
Never run containers as root. Create a dedicated user for security.
Layer Caching
Copy dependency files (pom.xml, package.json) before source code so deps are cached.
Use .dockerignore
Exclude node_modules, .git, target/ from build context to speed up builds.