Skip to main content

📘 DevOps Week 6 - Complete Kubernetes Fundamentals Guide ☸️ Part - 1

Learn Introduction to Kubernetes, Architecture, Cluster Management, Pods, Deployments, ReplicaSets, Services & Networking in Simple Language 🚀

Updated 35 min readMarkdown
Part of seriesDevOps Learning Journey 🚀
📘 DevOps Week 6 - Complete Kubernetes Fundamentals Guide ☸️ Part - 1

🔹 1. What is Kubernetes? ☸️

Kubernetes (K8s) is a container orchestration platform.

👉 It is used to:

  • Deploy containers

  • Manage containers

  • Scale containers

  • Monitor containers

automatically in production environments.


🔹 2. Why Kubernetes is Important? 🔥

In modern companies:

  • Applications are built using microservices

  • Hundreds or thousands of containers run together

Managing them manually becomes difficult.

👉 Kubernetes automates this entire process.


🔹 3. Prerequisite for Kubernetes 📚

Before learning Kubernetes, you should understand:

✅ Docker ✅ Containers ✅ Networking basics ✅ Container isolation


💡 Important Point

The instructor explains: 👉 Don’t just memorize Docker commands.

Instead understand:

  • How containers work

  • Namespace isolation

  • Networking

  • Container lifecycle

because Kubernetes works on top of containers.


🔹 4. Docker vs Kubernetes ⚔️


✔ Docker

Docker is a:

Container Platform

Used to:

  • Build containers

  • Run containers


✔ Kubernetes

Kubernetes is a:

Container Orchestration Platform

Used to:

  • Manage large-scale containers

  • Automate operations

  • Handle production workloads


🔹 5. Problems with Docker in Production ❌

Docker is excellent for running containers.

But in large production systems, Docker alone has limitations.

Kubernetes solves these problems.


🔹 6. Problem 1 – Single Host Limitation 🖥️


❌ Docker Problem

Docker usually works on:

Single Host

Meaning:

  • Containers run on one server only.

💡 Problem Scenario

If:

  • Server crashes

  • CPU becomes overloaded

Applications may go down.


✔ Kubernetes Solution

Kubernetes uses:

Cluster Architecture

A cluster = Multiple servers (nodes)


✔ Benefits

If one server fails: 👉 Kubernetes moves workload to another server automatically.


🔹 7. Problem 2 – Auto Healing 🚑


❌ Docker Problem

If a container crashes: 👉 Manual restart required.


✔ Kubernetes Solution

Kubernetes continuously monitors containers.

If a container fails: ✅ Automatically creates new container.


✔ This Feature is Called:

Auto Healing

🔹 8. Problem 3 – Auto Scaling 📈


❌ Docker Problem

Handling sudden traffic spikes is difficult manually.

Example:

  • Website traffic increases rapidly

  • One container cannot handle load


✔ Kubernetes Solution

Kubernetes supports:

Horizontal Pod Autoscaling (HPA)

✔ What Happens?

Kubernetes automatically:

  • Adds more containers when traffic increases

  • Removes extra containers when traffic decreases


✔ Benefits

✅ Better performance ✅ Cost optimization ✅ High availability


🔹 9. Problem 4 – Enterprise-Level Features 🏢


❌ Docker Limitation

Docker is minimalistic.

Large enterprises require:

  • Load balancing

  • Security

  • API gateways

  • Firewalling

  • Monitoring


✔ Kubernetes Solution

Kubernetes provides enterprise-level capabilities.


✔ Features Include

✅ Load balancing ✅ Service discovery ✅ Networking ✅ Security policies ✅ Scalability ✅ High availability


🔹 10. Kubernetes Origin 🌍

Kubernetes was inspired by:

Google Borg Project

Google used Borg internally to manage massive infrastructure.

Kubernetes brings similar concepts to modern cloud environments.


🔹 11. Kubernetes Cluster Architecture ☸️

Kubernetes works using:

  • Master Node

  • Worker Nodes


✔ Worker Nodes

Run applications/containers.


✔ Master Node

Controls the cluster:

  • Scheduling

  • Monitoring

  • Management


🔹 12. What is a Pod? 📦

Kubernetes does not directly run containers.

Instead it runs:

Pods

A Pod contains:

  • One or more containers


✔ Automation

Reduces manual work.


✔ Scalability

Handles traffic automatically.


✔ Reliability

Auto-healing improves uptime.


✔ Cloud Native

Works well with:

  • AWS

  • Azure

  • GCP


🔹 14. Real DevOps Use Cases 💡


✔ Microservices Architecture

Different services deployed independently.


✔ Large Applications

Used by:

  • Netflix

  • Spotify

  • Google

  • Amazon


✔ CI/CD Pipelines

Kubernetes integrates with DevOps automation tools.


🔹 15. Kubernetes Future Learning 📚

Upcoming Kubernetes concepts include:

  • Pods

  • Deployments

  • Services

  • Ingress Controllers

  • ConfigMaps

  • Secrets


🔹 16. Docker vs Kubernetes Summary 🔥

Docker Kubernetes
Container platform Orchestration platform
Single host Multi-node cluster
Manual recovery Auto healing
Limited scaling Auto scaling
Basic features Enterprise-ready

🔹 17. Important Interview Questions 🔥


✔ What is Kubernetes?

Container orchestration platform.


✔ Why Kubernetes?

To manage containers automatically at scale.


✔ Difference between Docker & Kubernetes?

Docker runs containers. Kubernetes manages containers.


✔ What is Auto Healing?

Automatically recreating failed containers.


✔ What is HPA?

Horizontal Pod Autoscaler.

Automatically scales pods based on traffic

Kubernetes Architecture Explained with Examples


🔹 1. What is Kubernetes Architecture? ☸️

Kubernetes architecture defines:

  • How Kubernetes manages applications

  • How containers communicate

  • How workloads are distributed

Kubernetes works using:

Control Plane + Worker Nodes

🔹 2. Two Main Parts of Kubernetes Architecture 🏗️

Part Purpose
Control Plane Manages cluster
Data Plane (Worker Nodes) Runs applications

🔹 3. Understanding with Real-Life Example 💡

Imagine:

🧠 Control Plane = School Principal 👨‍🏫 Worker Nodes = Classrooms 👨‍🎓 Containers = Students

The principal:

  • Gives instructions

  • Manages classrooms

  • Decides student allocation

The classrooms:

  • Actually run daily activities

Similarly:

  • Control Plane manages

  • Worker Nodes execute


🔹 A. Data Plane (Worker Nodes) 🖥️

Worker nodes are responsible for: ✅ Running applications ✅ Executing containers ✅ Managing workloads

Each worker node contains 3 important components.


🔹 a. Container Runtime 📦

Examples:

  • containerD

  • CRI-O

  • Docker (older setups)


✔ Purpose

Container runtime is responsible for:

Running containers

✔ Real-Life Example

Like:

Engine of a car

Without engine:

  • Car cannot run

Without container runtime:

  • Containers cannot run

🔹 b. Kubelet 🔥

Kubelet is the:

Primary agent on worker node

✔ Responsibilities

Kubelet:

  • Talks to control plane

  • Starts containers

  • Monitors pods

  • Ensures containers stay running


✔ Real-Life Example

Kubelet acts like:

Class monitor

It continuously checks:

  • Is application running properly?

  • Did any pod fail?


✔ Important Point

If a pod crashes: 👉 Kubelet helps restart it.


🔹 c. Kube-Proxy 🌐

Kube-Proxy handles:

  • Networking

  • Communication

  • Load balancing

between pods/services.


✔ Responsibilities

✅ Assigns IP addresses ✅ Routes traffic ✅ Enables pod communication


✔ Real-Life Example

Kube-Proxy works like:

Traffic police

Directing traffic properly between applications.


🔹 B. Control Plane (Master Node) 🧠

The control plane is:

Brain of Kubernetes

It manages the entire cluster.


🔹 a. API Server ❤️

API Server is:

Heart of Kubernetes

✔ Responsibilities

All requests first go to:

API Server

Examples:

  • kubectl commands

  • UI requests

  • Internal communication


✔ Real-Life Example

Like:

Reception desk of office

Every request first reaches reception.


🔹 b. Scheduler 📍

Scheduler decides:

Where pods should run

✔ How Scheduler Works

It checks:

  • CPU usage

  • Memory availability

  • Resource health

Then selects best worker node.


✔ Example

If:

  • Node 1 overloaded

  • Node 2 free

Scheduler places pod on Node 2.


🔹 c. etcd 🗄️

etcd is:

Key-value database

✔ Purpose

Stores:

  • Cluster configuration

  • Node information

  • Pod details

  • Secrets

  • Current cluster state


✔ Important Point

etcd is called:

Source of Truth

because Kubernetes stores all important data here.


✔ Real-Life Example

Like:

School records database

Stores complete information.


🔹 d. Controller Manager 🔄

Controller Manager ensures:

Desired state = Actual state

✔ Example

Suppose: You want:

3 pods running

If 1 pod crashes: 👉 Controller Manager creates new pod automatically.


✔ Responsibilities

✅ Monitoring ✅ Auto healing ✅ Replica management


🔹 e. Cloud Controller Manager (CCM) ☁️

Used mainly in:

  • AWS

  • Azure

  • GCP


✔ Purpose

Connects Kubernetes with cloud provider APIs.


✔ Example

If Kubernetes needs:

  • Load balancer

  • Storage

  • Public IP

CCM talks to cloud provider.


✔ Real-Life Example

Like:

Translator between Kubernetes and Cloud

🔹Kubernetes Workflow 🔄


✔ Step-by-Step Flow

Step 1

User sends request using:

kubectl apply

Step 2

Request goes to:

API Server

Step 3

Scheduler selects worker node.


Step 4

Kubelet receives instruction.


Step 5

Container Runtime starts container.


Step 6

Kube-Proxy handles networking.


🔹 Kubernetes Architecture Diagram (Simple Flow) 📊

User
 ↓
API Server
 ↓
Scheduler
 ↓
Worker Node
 ↓
Kubelet
 ↓
Container Runtime
 ↓
Pods Running

🔹Why Kubernetes Architecture is Powerful? 🚀


✔ High Availability

Applications stay available.


✔ Auto Healing

Failed pods restart automatically.


✔ Scalability

Easily handles traffic spikes.


✔ Enterprise Ready

Supports:

  • Monitoring

  • Security

  • Load balancing


🔹 Control Plane vs Worker Node ⚔️

Control Plane Worker Node
Manages cluster Runs applications
Makes decisions Executes tasks
Brain of Kubernetes Work machine
Handles scheduling Runs pods

🔹Important Interview Questions 🔥


✔ What is Control Plane?

Manages Kubernetes cluster.


✔ What is Worker Node?

Runs containers and applications.


✔ What is API Server?

Central communication gateway.


✔ What is etcd?

Key-value database storing cluster state.


✔ What is Kubelet?

Agent running on worker nodes.


✔ What is Scheduler?

Selects best node for pod placement.


✔ What is Kube-Proxy?

Handles networking and load balancing.


How to Manage Hundreds of Kubernetes Clusters? ☸️🚀


🔹 Why Managing Kubernetes Clusters is Difficult? 🤔

In real production environments:

  • Companies run multiple applications

  • Applications are distributed across many clusters

  • Infrastructure grows rapidly

Managing everything manually becomes: ❌ Complex ❌ Time-consuming ❌ Error-prone


🔹 Development vs Production Kubernetes ⚔️

✔ Development Environment

Used for:

  • Practice

  • Learning

  • Testing

Common Development Tools

Tool Purpose
Minikube Local Kubernetes cluster
kind Kubernetes in Docker
k3s Lightweight Kubernetes

Important Note

These tools are:

NOT recommended for production

because they are mainly designed for local learning and testing.


✔ Production Environment

Production systems require: ✅ High availability ✅ Security ✅ Scalability ✅ Enterprise support ✅ Monitoring ✅ Backup & recovery


🔹 What Do Companies Use in Production? 🏢

Instead of raw Kubernetes, organizations use:

Kubernetes Distributions

🔹 What is a Kubernetes Distribution? 📦

A Kubernetes distribution is:

Production-ready Kubernetes package

with:

  • Security features

  • Monitoring

  • Management tools

  • Enterprise support


Distribution Provider
OpenShift Red Hat
Rancher SUSE
VMware Tanzu VMware
EKS AWS
AKS Azure
GKE Google Cloud

Managed services like:

  • AWS EKS

  • Azure AKS

  • Google GKE

reduce operational burden.

Cloud Provider Handles

✅ Control plane management ✅ Upgrades ✅ High availability ✅ Security patches

DevOps Engineer Focuses On

✅ Applications ✅ Deployments ✅ Scaling ✅ Monitoring


🔹 What is KOPS? ⚙️

KOPS stands for:

Kubernetes Operations

Purpose of KOPS

KOPS helps manage:

  • Kubernetes cluster creation

  • Upgrades

  • Configuration

  • Deletion


🔹 Why KOPS is Important? 🚀

In enterprises:

  • Hundreds of clusters may exist

Manually handling them is impossible.

KOPS automates cluster lifecycle management.


🔹 Real DevOps Use Case 💡

Suppose a company has:

  • 100 microservices

  • Multiple regions

  • Separate dev/staging/prod clusters

KOPS helps: ✅ Create clusters quickly ✅ Maintain consistency ✅ Simplify operations


🔹 KOPS Workflow 🔄

✔ Install Required Tools

Required tools:

  • AWS CLI

  • Python 3

  • kubectl

  • KOPS


✔ Configure AWS

Need: ✅ AWS IAM permissions ✅ AWS credentials


✔ Create S3 Bucket

KOPS uses:

S3 bucket as state storage

Why S3 Bucket?

Stores:

  • Cluster configuration

  • Metadata

  • State information


✔ Create Cluster

KOPS uses commands to:

  • Create cluster

  • Configure networking

  • Launch EC2 instances


✔ Validate Cluster

After creation:

kubectl get nodes

checks whether cluster is running properly.


🔹 Why S3 State Store is Important? 🗄️

KOPS continuously tracks:

  • Cluster state

  • Infrastructure changes

using S3 storage.

Benefits

✅ Backup ✅ Easy recovery ✅ Centralized management


🔹 Important Production Concepts 🔥

✔ High Availability

Production clusters require:

  • Multiple nodes

  • Redundancy

  • Failover systems


✔ Security

Clusters must secure:

  • APIs

  • Networking

  • Secrets

  • IAM access


✔ Monitoring

Production environments use:

  • Prometheus

  • Grafana

  • ELK Stack


✔ Scaling

Clusters should automatically:

  • Scale applications

  • Handle traffic spikes


🔹 Cost Warning ⚠️

The instructor clearly mentions:

Creating Kubernetes clusters on AWS:

WILL incur charges

✔ Recommendation for Beginners

Use:

  • Minikube

  • kind

  • k3s

for local practice.


🔹 Why Minikube is Good for Beginners? 💻

Minikube: ✅ Runs locally ✅ Free for learning ✅ Easy to install ✅ Good for practice


🔹 Real-World DevOps Responsibilities 👨‍💻

A DevOps Engineer may handle:

  • Cluster upgrades

  • Security patches

  • Node management

  • Monitoring

  • Disaster recovery

  • Scaling infrastructure


🔹 Difference Between Minikube & EKS ⚔️

Minikube AWS EKS
Local learning Production-grade
Single node Multi-node cluster
Free/local Paid cloud service
Beginner practice Enterprise usage

🔹 Important Commands Mentioned 🧾

✔ Check Kubernetes Nodes

kubectl get nodes

✔ Create Cluster with KOPS

kops create cluster

✔ Update Cluster

kops update cluster

✔ Validate Cluster

kops validate cluster

🔹 Important Interview Questions 🔥

✔ What is KOPS?

Tool used to manage Kubernetes cluster lifecycle.


✔ Why use Kubernetes distributions?

Provides production-ready Kubernetes with enterprise support.


✔ Why is Minikube not used in production?

It is designed only for local development/testing.


✔ What is EKS?

Managed Kubernetes service by AWS.


✔ Why use S3 bucket in KOPS?

To store cluster state and configuration.


Kubernetes Pods | Deploy Your First App ☸️


🔹 Introduction to Kubernetes Pods ☸️

Kubernetes uses:

Pods

to run applications.

A Pod is the:

Smallest deployable unit in Kubernetes

Instead of directly managing containers, Kubernetes manages Pods.


🔹 Why Kubernetes Uses Pods? 🤔

In Docker:

  • We directly run containers.

But Kubernetes introduces:

Pods as wrappers around containers

This provides: ✅ Better orchestration ✅ Easier scaling ✅ Auto healing ✅ Better networking ✅ Enterprise-level management


🔹 What is a Pod? 📦

A Pod is:

A wrapper that contains one or more containers

🔹 Simple Real-Life Example 💡

Imagine:

📦 Container = Mobile App 📱 Pod = Mobile Phone

The app runs inside the phone.

Similarly:

  • Containers run inside Pods.

🔹 Container vs Pod ⚔️

Container Pod
Runs application Wraps container
Docker manages it Kubernetes manages it
Lightweight runtime Smallest deployable unit
Independent Can contain multiple containers

🔹 Why Pods are Important? 🚀

Pods help Kubernetes provide: ✅ Auto scaling ✅ Auto healing ✅ Networking ✅ Resource management ✅ Service discovery


🔹 Single Container Pod 📦

Most commonly:

1 Pod = 1 Container

Example:

  • One Nginx container inside one Pod.

🔹 Multi-Container Pod 🧩

Sometimes:

1 Pod = Multiple Containers

Used when containers must:

  • Share storage

  • Share networking

  • Work closely together


🔹 What is kubectl? 🛠️

kubectl is:

Command Line Interface for Kubernetes

Used to:

  • Create resources

  • Manage Pods

  • Check logs

  • Debug issues


🔹 What is Minikube? 💻

Minikube is:

Local Kubernetes cluster

used for:

  • Practice

  • Learning

  • Testing Kubernetes locally


🔹 Why Minikube is Good for Beginners? 🚀

Minikube: ✅ Easy to install ✅ Free for learning ✅ Runs locally ✅ Good for Kubernetes practice


🔹 Installing Kubernetes Tools 🔧

The video demonstrates installing:

  • kubectl

  • Minikube

These tools are required for:

Running Kubernetes locally

🔹 Creating Your First Kubernetes App 🚀

Applications in Kubernetes are usually created using:

YAML files

🔹 What is YAML? 📄

YAML is:

Configuration language

used to define:

  • Pods

  • Deployments

  • Services

  • Configurations


🔹 Example Pod YAML File 📄

apiVersion: v1
kind: Pod

metadata:
  name: nginx-pod

spec:
  containers:
  - name: nginx-container
    image: nginx

🔹 Understanding the YAML File 🧠

Field Purpose
apiVersion Kubernetes API version
kind Resource type
metadata Pod name/details
spec Container configuration
image Docker image name

🔹 Deploying the Pod 🚀

Command used:

kubectl create -f pod.yaml

🔹 What This Command Does? 🤔

It tells Kubernetes: ✅ Read YAML file ✅ Create Pod ✅ Pull Docker image ✅ Start container inside Pod


🔹 Checking Running Pods 👀

Command:

kubectl get pods

🔹 Output Example

NAME         READY   STATUS    RESTARTS
nginx-pod    1/1     Running   0

🔹 Important Debugging Commands 🛠️

Kubernetes debugging is very important for DevOps engineers.


🔹 Describe Pod Command 🔍

kubectl describe pod nginx-pod

✔ Purpose

Shows:

  • Pod events

  • Status

  • Errors

  • Networking details

  • Resource information


🔹 Logs Command 📜

kubectl logs nginx-pod

✔ Purpose

Used to:

  • View application logs

  • Debug application issues

  • Detect failures/errors


🔹 Common Pod Problems ⚠️

Sometimes Pods may fail because of:

  • Wrong image name

  • Port issues

  • Insufficient resources

  • Application crash


🔹 Why Debugging is Important? 🔥

DevOps engineers frequently troubleshoot: ✅ Failed Pods ✅ CrashLoopBackOff errors ✅ Networking issues ✅ Resource issues


🔹 Pod Lifecycle 🔄

Basic lifecycle:

Create Pod
 ↓
Image Pull
 ↓
Container Start
 ↓
Running State
 ↓
Stopped/Deleted

🔹 Why Pods Alone Are Not Enough? 🤔

Pods are foundational, but in production companies prefer:

Deployments

because Pods alone do not provide: ❌ Auto healing ❌ Auto scaling ❌ Replica management


🔹 What are Deployments? 🚀

Deployments help: ✅ Automatically recreate failed Pods ✅ Scale applications ✅ Manage updates/rollbacks


🔹 Kubernetes vs Docker 🚀

Docker Kubernetes
Runs containers Orchestrates containers
Manual scaling Auto scaling
Limited auto healing Built-in auto healing
Single host focus Cluster management

🔹 Real DevOps Use Cases 💡

Kubernetes Pods are used for:

  • Hosting web applications

  • Running APIs

  • Microservices deployment

  • Backend services

  • CI/CD applications


🔹 Important Interview Questions 🔥

✔ What is a Pod?

Smallest deployable unit in Kubernetes.


✔ Difference between Pod and Container?

Pod wraps one or more containers.


✔ What is kubectl?

CLI tool used to manage Kubernetes.


✔ What is Minikube?

Local Kubernetes cluster for learning/testing.


✔ How to check Pod logs?

kubectl logs <pod-name>

✔ How to describe Pod details?

kubectl describe pod <pod-name>

Kubernetes Deployments & ReplicaSets ☸️🚀


🔹 Introduction to Kubernetes Deployments 🚀

In Kubernetes, Pods are the smallest deployable units.

But in real production environments:

Pods are rarely managed directly

Instead, organizations use:

Deployments

because Deployments provide: ✅ Auto healing ✅ Scaling ✅ High availability ✅ Rolling updates ✅ Zero downtime


🔹 Container vs Pod vs Deployment ⚔️

Understanding this hierarchy is very important.


✔ Container 📦

A container:

Runs the application

Example:

  • Nginx container

  • Python app container


✔ Pod ☸️

A Pod:

Wraps one or more containers

It provides:

  • Shared networking

  • Shared storage

  • Kubernetes management


✔ Deployment 🚀

A Deployment:

Manages Pods automatically

It ensures:

  • Correct number of Pods

  • Auto recovery

  • Scaling

  • Smooth updates


🔹 Simple Real-Life Example 💡

Imagine:

👨‍🍳 Container = Chef 🍽️ Pod = Kitchen 🏢 Deployment = Restaurant Manager

The manager:

  • Ensures enough kitchens exist

  • Replaces failed kitchens

  • Handles scaling during rush hours

Similarly: Deployments manage Pods automatically.


🔹 Why Pods Alone Are Not Enough? 🤔

If you directly create Pods: ❌ No automatic recovery ❌ No scaling ❌ No rolling updates ❌ No production reliability

If a Pod crashes:

Application may go down

🔹 What is a Deployment? 📄

A Deployment is:

A Kubernetes object used to manage Pods

Deployments automatically: ✅ Create Pods ✅ Replace failed Pods ✅ Scale Pods ✅ Update applications safely


🔹 What is a ReplicaSet? 🔄

A ReplicaSet is:

A Kubernetes controller

that ensures:

Desired number of Pods are always running

🔹 Important Relationship 🧠

Deployment → Creates ReplicaSet → Manages Pods

🔹 Deployment Architecture 📊

Deployment
    ↓
ReplicaSet
    ↓
Pods
    ↓
Containers

🔹 What Does ReplicaSet Do? 🚀

ReplicaSet continuously checks:

  • How many Pods should run

  • How many Pods are currently running

If mismatch happens: 👉 ReplicaSet fixes it automatically.


🔹 Example of ReplicaSet 💡

Suppose:

Desired replicas = 3

Current running:

Only 2 Pods

ReplicaSet automatically: ✅ Creates 1 more Pod


🔹 Auto-Healing in Kubernetes ❤️

One of the biggest advantages of Deployments is:

Auto Healing

✔ What is Auto Healing?

If a Pod crashes or gets deleted:

ReplicaSet automatically creates a new Pod

without manual intervention.


🔹 Real Production Scenario 💼

Suppose: Your company website is running on Kubernetes.

If one Pod crashes: ❌ Website should NOT go down.

Kubernetes automatically: ✅ Detects failure ✅ Creates replacement Pod ✅ Keeps application available


🔹 Zero Downtime Deployment 🔥

Kubernetes Deployments support:

Zero Downtime Updates

✔ What Does This Mean?

Applications continue running while:

  • New Pods are created

  • Old Pods are removed gradually

Users experience: ✅ No service interruption


🔹 Scaling Applications 📈

Deployments make scaling easy.


✔ Example

Initially:

1 Pod running

Traffic increases suddenly.

Deployment can scale:

1 → 3 → 10 Pods

to handle more users.


🔹 Kubernetes Deployment YAML 📄

Example:

apiVersion: apps/v1
kind: Deployment

metadata:
  name: nginx-deployment

spec:
  replicas: 3

  selector:
    matchLabels:
      app: nginx

  template:
    metadata:
      labels:
        app: nginx

    spec:
      containers:
      - name: nginx
        image: nginx

🔹 Understanding Deployment YAML 🧠

Field Purpose
apiVersion Kubernetes API version
kind Resource type
replicas Number of Pods
selector Pod matching label
template Pod definition
image Container image

🔹 Creating Deployment 🚀

Command:

kubectl create -f deployment.yaml

🔹 Checking Deployments 👀

Command:

kubectl get deployments

🔹 Checking ReplicaSets 🔄

Command:

kubectl get rs

🔹 Checking Pods ☸️

Command:

kubectl get pods

🔹 Scaling Deployment 📈

Command:

kubectl scale deployment nginx-deployment --replicas=5

✔ Result

Kubernetes automatically creates:

5 Pods

🔹 What Happens if Pod Gets Deleted? ⚠️

Suppose: You manually delete one Pod.

ReplicaSet immediately: ✅ Detects missing Pod ✅ Creates replacement Pod

This is:

Auto Healing

🔹 Deployment Benefits 🚀

Deployments provide: ✅ High availability ✅ Auto healing ✅ Easy scaling ✅ Rolling updates ✅ Rollbacks ✅ Zero downtime


🔹 Real DevOps Use Cases 💼

Deployments are used for:

  • Web applications

  • APIs

  • Microservices

  • Banking applications

  • E-commerce platforms

  • CI/CD applications


🔹 Rolling Updates 🔄

When updating application version: Kubernetes: ✅ Creates new Pods gradually ✅ Removes old Pods safely

This avoids: ❌ Application downtime


🔹 Rollback Feature ⏪

If deployment update fails: Kubernetes can:

Rollback to previous version

very easily.


🔹 Difference Between Pod & Deployment ⚔️

Pod Deployment
Basic unit Manages Pods
Manual management Automatic management
No scaling Supports scaling
No auto healing Auto healing
Not production-ready Production-ready

🔹 Important kubectl Commands 🧾


✔ Create Deployment

kubectl create -f deployment.yaml

✔ Get Deployments

kubectl get deployments

✔ Get ReplicaSets

kubectl get rs

✔ Get Pods

kubectl get pods

✔ Scale Deployment

kubectl scale deployment nginx-deployment --replicas=5

✔ Describe Deployment

kubectl describe deployment nginx-deployment

🔹 Important Interview Questions 🔥

✔ What is Deployment in Kubernetes?

Deployment manages Pods automatically.


✔ What is ReplicaSet?

Controller ensuring desired number of Pods are running.


✔ What is Auto Healing?

Automatic recreation of failed Pods.


✔ Why use Deployments instead of Pods?

Deployments provide:

  • Scaling

  • Auto healing

  • Rolling updates


✔ What is Zero Downtime Deployment?

Application remains available during updates.


Everything About Kubernetes Services ☸️🌐


🔹 Introduction to Kubernetes Services 🚀

In Kubernetes, applications run inside:

Pods

But Pods are:

Temporary (Ephemeral)

This means:

  • Pods can crash

  • Pods can be recreated

  • Pod IP addresses can change

Because of this:

Direct communication with Pods becomes unreliable

🔹 The Main Problem Without Services ❌

Suppose: Your application is running inside a Pod.

Users access it using:

Pod IP Address

Now if:

  • Pod crashes

  • ReplicaSet creates new Pod

Then:

New Pod gets a NEW IP address

Result: ❌ Users lose connection ❌ Applications become inaccessible


🔹 Why Kubernetes Services Are Needed? 💡

Kubernetes Services solve this issue by providing: ✅ Stable networking ✅ Fixed access point ✅ Load balancing ✅ Service discovery


🔹 What is a Kubernetes Service? ☸️

A Kubernetes Service is:

A stable networking layer in front of Pods

It acts like:

A permanent entry point for applications

Even if Pods change, the Service remains constant.


🔹 Real-Life Example 💡

Imagine:

🏪 Shop workers = Pods 🏢 Shop reception desk = Service

Customers do NOT directly contact workers.

Instead:

  • They contact reception

  • Reception forwards requests

Similarly: Kubernetes Service forwards traffic to Pods.


🔹 Main Functions of Kubernetes Services 🔥

Services mainly provide: ✅ Load Balancing ✅ Service Discovery ✅ Stable Access


🔹 What is Load Balancing? ⚖️

Load balancing means:

Distributing traffic across multiple Pods

🔹 Example of Load Balancing 💡

Suppose: You have:

3 Pod replicas

100 users visit the application.

Instead of sending all traffic to one Pod: Kubernetes distributes requests among:

  • Pod 1

  • Pod 2

  • Pod 3

Result: ✅ Better performance ✅ Better reliability ✅ Reduced overload


🔹 Why Load Balancing is Important? 🚀

Without load balancing: ❌ One Pod may crash due to heavy traffic

With load balancing: ✅ Traffic is shared equally


🔹 What is Service Discovery? 🔍

Service discovery means:

Automatically finding Pods dynamically

Because Pod IPs change frequently, Services use:

Labels & Selectors

to identify Pods.


🔹 What are Labels in Kubernetes? 🏷️

Labels are:

Key-value pairs attached to Pods

Example:

labels:
  app: nginx

🔹 What are Selectors? 🎯

Selectors are used by Services to:

Find matching Pods

Example:

selector:
  app: nginx

🔹 How Labels & Selectors Work Together 🔄

Suppose: Pods contain label:

app=nginx

Service selector searches:

app=nginx

Result: ✅ Service automatically connects to matching Pods


🔹 Kubernetes Service Workflow 🔄

User Request
      ↓
Kubernetes Service
      ↓
Load Balancing
      ↓
Matching Pods

🔹 Kubernetes Service YAML Example 📄

apiVersion: v1
kind: Service

metadata:
  name: nginx-service

spec:
  selector:
    app: nginx

  ports:
  - protocol: TCP
    port: 80
    targetPort: 80

  type: ClusterIP

🔹 Understanding Service YAML 🧠

Field Purpose
kind Resource type
selector Finds matching Pods
port Service port
targetPort Pod container port
type Service type

🔹 Types of Kubernetes Services 🌐

Kubernetes mainly provides:

  • ClusterIP

  • NodePort

  • LoadBalancer


🔹 ClusterIP Service 🔒

ClusterIP is:

Default Kubernetes Service type

✔ Purpose

Allows communication:

ONLY inside the Kubernetes cluster

✔ Use Cases

Used for:

  • Internal microservices

  • Backend APIs

  • Database communication


✔ Example

Frontend Pod communicates with Backend Pod internally.


✔ Access Scope

Internal Cluster Only

🔹 NodePort Service 🌍

NodePort exposes applications using:

Worker Node IP + Port

✔ Purpose

Allows external access to applications.


✔ How It Works

Kubernetes opens:

Specific port on every worker node

Users access:

<Node-IP>:<NodePort>

✔ Use Cases

Useful for:

  • Testing

  • Internal organization access

  • Development environments


✔ Example

192.168.1.10:30007

🔹 LoadBalancer Service ☁️

LoadBalancer is:

Cloud-provider integrated service

✔ Purpose

Exposes application publicly to the internet.


✔ How It Works

In cloud platforms like:

  • AWS

  • Azure

  • GCP

Kubernetes automatically provisions: ✅ External Load Balancer ✅ Public IP address


✔ Use Cases

Used for:

  • Public websites

  • Production applications

  • Internet-facing services


🔹 Service Types Comparison ⚔️

Service Type Access Scope Use Case
ClusterIP Internal only Internal communication
NodePort External via Node IP Testing/Internal access
LoadBalancer Public internet Production apps

🔹 Why Services are Important in Production? 🚀

Services provide: ✅ High availability ✅ Stable networking ✅ Scalable architecture ✅ Reliable communication


🔹 Auto-Healing & Services ❤️

When Pods fail:

  • New Pods get new IPs

But Services automatically: ✅ Detect new Pods ✅ Continue routing traffic

Users never notice backend changes.


🔹 Kubernetes Networking Basics 🌐

Each Pod gets: ✅ Unique IP address

But because Pods are temporary, Services create:

Stable communication layer

🔹 Real DevOps Use Cases 💼

Services are used in:

  • E-commerce applications

  • Banking apps

  • Microservices architecture

  • APIs

  • Kubernetes production clusters


🔹 Example Architecture 💡

Users
   ↓
LoadBalancer Service
   ↓
Frontend Pods
   ↓
ClusterIP Service
   ↓
Backend Pods
   ↓
Database

🔹 Important kubectl Commands 🧾


✔ Get Services

kubectl get svc

✔ Describe Service

kubectl describe svc nginx-service

✔ Create Service

kubectl apply -f service.yaml

✔ Get Pods

kubectl get pods

🔹 Important Interview Questions 🔥

✔ What is a Kubernetes Service?

Stable networking layer for Pods.


✔ Why are Services needed?

Because Pod IP addresses change dynamically.


✔ What is Load Balancing?

Distributing traffic across multiple Pods.


✔ What is Service Discovery?

Automatically identifying Pods using labels/selectors.


✔ Difference between ClusterIP & NodePort?

ClusterIP is internal only, NodePort allows external access.


✔ Which Service type exposes application publicly?

LoadBalancer Service.



🚀 Continue Your Learning Journey

Thank you for taking the time to read this article.

Technology is evolving rapidly, and continuous learning is one of the most valuable investments you can make in your career. Whether you're exploring DevOps, Cloud Computing, Artificial Intelligence, Cybersecurity, Software Development, Data Science, or Career Growth, the resources below can help you deepen your knowledge and stay ahead in the industry.


🎓 Recommended Learning Platforms

🚀 Coursera

Learn from world-renowned universities and industry leaders including Google, IBM, Stanford, Microsoft, Meta, and many more.

✔ Professional Certificates ✔ Career-focused Learning Paths ✔ AI & Machine Learning Programs ✔ Cloud & DevOps Certifications ✔ Business & Leadership Courses

🔗 https://imp.i384100.net/k0KvbV


💻 Udemy

One of the largest online learning platforms with practical, hands-on courses covering:

✔ DevOps & Kubernetes ✔ Docker & Cloud Computing ✔ AWS, Azure & GCP ✔ Programming & Development ✔ Cybersecurity & Ethical Hacking

🔗 https://trk.udemy.com/MAL2MY


📊 DataCamp

A great platform for anyone interested in:

✔ Python Programming ✔ SQL & Databases ✔ Data Analytics ✔ Machine Learning ✔ Artificial Intelligence

Interactive learning paths and hands-on projects make it ideal for beginners and professionals alike.

🔗 https://datacamp.pxf.io/nX4kER


🎓 edX

Access high-quality courses and certifications from leading institutions such as:

✔ Harvard University ✔ MIT ✔ Berkeley ✔ Microsoft

Perfect for learners seeking university-level education online.

🔗 https://edx.sjv.io/POvVeN


🎨 Domestika

Enhance your creative skills with courses on:

✔ Graphic Design ✔ Video Editing ✔ Animation ✔ Digital Marketing ✔ Content Creation

🔗 https://domestika.sjv.io/dynKAW


🛠️ Recommended Tools & Resources

🔥 AppSumo

Discover exclusive lifetime deals on:

✔ AI Tools ✔ Productivity Software ✔ Developer Utilities ✔ Marketing Platforms ✔ Business Applications

A must-have resource for developers, creators, freelancers, and entrepreneurs looking to save money while accessing premium tools.

🔗 https://appsumo.8odi.net/L04a33


🛒 Shopify

Looking to start an online business or launch an eCommerce store?

Shopify provides everything you need to build, manage, and scale an online business.

✔ Online Store Builder ✔ Payment Integration ✔ Inventory Management ✔ Marketing Tools

🔗 https://shopify.pxf.io/Vxv09k


🌐 WordPress, WooCommerce & Jetpack

Create professional websites, blogs, and online stores with one of the most trusted web ecosystems in the world.

Ideal for:

✔ Personal Blogs ✔ Portfolio Websites ✔ Business Websites ✔ eCommerce Stores

🔗 https://automattic.pxf.io/Z6vR5W


🌍 Language Learning Resources

🗣️ Preply

Learn English and other languages through personalized one-on-one tutoring sessions with experts from around the world.

🔗 https://preply.sjv.io/o4gBDY


📚 British Council English Online

Improve your professional communication skills and English fluency through structured learning programs.

🔗 https://englishonline.sjv.io/9VOGa4


🧠 Rosetta Stone

One of the most recognized language-learning platforms for immersive language acquisition.

🔗 https://aff.rosettastone.com/X4OyqG


🧪 Science & Educational Resources

🔬 MEL Science

Interactive science kits and educational experiences designed to make STEM learning engaging and practical.

🔗 https://imp.i328067.net/bk2beg


📖 Carson Dellosa Education

Educational materials and learning resources for students, teachers, and lifelong learners.

🔗 https://carsondellosaeducation.sjv.io/E0JbjW


❤️ Support My Work

Creating detailed technical content, tutorials, guides, and learning resources takes significant time and effort.

If you find my articles helpful and would like to support my work, you can do so through the following platforms:

⭐ Become a GitHub Sponsor

Support my open-source contributions, technical content, and community projects.

🔗 https://github.com/sponsors/hritikranjan1


☕ Buy Me a Chai

Enjoying my content? Consider buying me a chai and supporting future tutorials, guides, and educational resources.

🔗 https://www.chai4.me/hritikranjan


👨‍💻 Connect With Me

Hritik Ranjan

💡 AI Enthusiast ☁️ DevOps Learner 🔐 Cybersecurity Advocate 💻 Software Developer

Connect & Follow

🔗 GitHub: https://github.com/hritikranjan1

🔗 LinkedIn: https://linkedin.com/in/hritikranjan1


📢 Found This Article Helpful?

If this article added value to your learning journey:

✅ Share it with your network
✅ Bookmark it for future reference
✅ Follow for more DevOps, AI, Cloud, Cybersecurity, and Software Engineering content

Thank you for reading and being part of this learning journey.

Keep Learning. Keep Building. Keep Growing. 🚀

About the author

  • 👋 Hi, I’m Hritik Ranjan — a B.Tech CSE student and a passionate tech enthusiast focused on Quality Engineering, AI/ML, Cybersecurity, and DevOps. 💡 I enjoy building and testing scalable, secure, and intelligent systems that solve real-world problems. My expertise and interests include: 🔹 Quality Assurance & Testing Hands-on experience in manual and automation testing using Selenium & Java, ensuring high-quality and reliable applications. 🔹 Artificial Intelligence & Machine Learning Exploring advanced algorithms and developing intelligent systems for practical use cases. 🔹 Cybersecurity Focused on vulnerability assessment, security testing, and system hardening. 🔹 Web Development Building responsive and user-friendly applications using modern technologies. 🔹 Data Science Analyzing complex data to extract actionable insights. 💼 Key Projects: 🚀 Blindness Detection System Applied computer vision techniques to detect blindness-related conditions. 🚀 AI-Powered Rail Madad Enhancement Developed an intelligent complaint management system to improve railway customer service. 🚀 Interactive Applications Built multiple projects like quiz apps, calculators, and productivity tools. 🌱 I’m continuously learning and improving my skills in DevOps, Cloud, and Automation to become a well-rounded engineer. 🤝 Open to collaborations, internships, and opportunities in QA, DevOps, AI/ML, and Cybersecurity. 📫 Let’s connect: hritikranjan1408@gmail.com

No comments yet. Be the first to comment.

DevOps Learning Journey 🚀

Part 7 of 14

Documenting my step-by-step journey of learning DevOps — from basics to advanced concepts. In this series, I’ll share weekly notes, hands-on practice, tools, and real-world insights as I grow in DevOps.

Up next📘 DevOps Week 6.1 – Kubernetes Interview Questions & Real-World Scenarios ☸️Learn Kubernetes Interview Questions, Beginner-Friendly Answers, Real Production Scenarios, Pods, Deployments, Services & Architecture Explained Simply 🚀

More from this blog