Posted in

πŸš€ Kubernetes Architecture and Its Working

Introduction

Kubernetes (K8s) is an open-source container orchestration platform used to automate the deployment, scaling, and management of containerized applications. It was originally developed by Google and is now maintained by the Cloud Native Computing Foundation (CNCF).

Kubernetes helps organizations run applications reliably in production by managing containers across clusters of machines.


πŸ— Kubernetes Architecture

A Kubernetes cluster consists of two major components:

  1. Control Plane (Master Node)
  2. Worker Nodes

🧠 1. Control Plane (Master Node)

The Control Plane manages the entire cluster. It makes decisions about scheduling, scaling, and maintaining the desired state of applications.

πŸ”Ή Components of Control Plane

1️⃣ API Server (kube-apiserver)

  • Entry point for all administrative tasks
  • Accepts REST requests (from kubectl, UI, or API calls)
  • Validates and processes requests
  • Communicates with etcd

2️⃣ etcd

  • Distributed key-value store
  • Stores cluster configuration and state
  • Maintains desired state information

3️⃣ Scheduler (kube-scheduler)

  • Assigns Pods to Worker Nodes
  • Makes decisions based on:
    • CPU & Memory availability
    • Node health
    • Resource requirements

4️⃣ Controller Manager

  • Runs controllers that monitor cluster state
  • Ensures actual state matches desired state
  • Examples:
    • ReplicaSet Controller
    • Node Controller
    • Deployment Controller

βš™οΈ 2. Worker Nodes

Worker nodes are responsible for running application containers.

πŸ”Ή Components of Worker Node

1️⃣ Kubelet

  • Agent running on each worker node
  • Communicates with API server
  • Ensures containers are running as defined

2️⃣ Kube-Proxy

  • Handles networking for Pods
  • Maintains network rules
  • Enables service communication and load balancing

3️⃣ Container Runtime

  • Responsible for running containers
  • Common runtimes:
    • Docker
    • containerd

πŸ“¦ Core Kubernetes Objects

Kubernetes works using declarative configuration (YAML files). Some important objects are:

πŸ”Ή Pod

  • Smallest deployable unit
  • Contains one or more containers
  • Shares network and storage

πŸ”Ή ReplicaSet

  • Maintains specified number of Pod replicas

πŸ”Ή Deployment

  • Manages ReplicaSets
  • Supports rolling updates and rollbacks

πŸ”Ή Service

  • Provides stable IP and DNS for Pods
  • Types:
    • ClusterIP
    • NodePort
    • LoadBalancer

πŸ”Ή ConfigMap & Secret

  • Store configuration data
  • Manage sensitive information securely

πŸ”„ How Kubernetes Works (Step-by-Step)

Let’s understand what happens when you deploy an application.

Step 1: Apply Configuration

kubectl apply -f deployment.yaml

Step 2: API Server Validates

  • Validates the request
  • Stores desired state in etcd

Step 3: Scheduler Assigns Node

  • Selects appropriate worker node
  • Assigns Pod

Step 4: Kubelet Creates Pod

  • Pulls container image
  • Starts container via runtime

Step 5: Service Routes Traffic

  • kube-proxy updates network rules
  • Load balances incoming traffic

πŸ” Self-Healing Mechanism

Kubernetes constantly compares:

Desired State vs Actual State

If:

  • Pod crashes
  • Node fails
  • Container stops

Kubernetes automatically:

  • Restarts container
  • Recreates Pod
  • Reschedules to another node

This ensures high availability.


πŸ“ˆ Scaling in Kubernetes

Manual Scaling

kubectl scale deployment my-app --replicas=5

Auto Scaling (HPA)

  • Based on CPU or memory usage
  • Automatically increases or decreases replicas

🌐 Kubernetes Networking Model

  • Each Pod gets a unique IP
  • Pods communicate directly within cluster
  • Services provide stable endpoint
  • Network policies secure communication

☁ Kubernetes in Cloud Platforms

Managed Kubernetes services include:

  • Amazon EKS
  • Google Kubernetes Engine
  • Azure Kubernetes Service

These services manage the Control Plane and simplify operations.


🎯 Benefits of Kubernetes

βœ… Automated deployment
βœ… Self-healing
βœ… Horizontal scaling
βœ… Rolling updates
βœ… Service discovery
βœ… Cloud portability


🧠 Conclusion

Kubernetes architecture is built around a powerful control plane and scalable worker nodes. It follows a declarative model where users define the desired state, and Kubernetes continuously works to maintain that state.

By automating deployment, scaling, and recovery, Kubernetes enables organizations to build resilient and highly available distributed systems.

Leave a Reply

Your email address will not be published. Required fields are marked *