Skip to main content

Command Palette

Search for a command to run...

πŸ“˜ 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 read
πŸ“˜ DevOps Week 6 - Complete Kubernetes Fundamentals Guide ☸️ Part - 1
H
πŸ‘‹ 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

πŸ”Ή 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. πŸš€

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

D

DevOps Journey by Hritik

14 posts

Started my DevOps journey from scratch, covering Linux, shell scripting, and a real-world AWS project for beginners.