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:
- Control Plane (Master Node)
- 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.