What is Kubernetes — Simple Explanation with Examples
Kubernetes (often abbreviated as K8s — the 8 replacing “ubernete”) is an open-source container orchestration platform. It automates deploying, scaling, load balancing, and managing containerized applications across a cluster of machines, freeing operators from manual management.
What You’ll Learn
This article covers Kubernetes core concepts — pods, nodes, deployments, services — with a working YAML example. You’ll understand what problems K8s solves, how it compares to Docker, and why it dominates cloud infrastructure. Kubernetes runs at Google, Netflix, Spotify, and most large-scale deployments.
The Problem Kubernetes Solves
Running containers with Docker alone works for one or two servers. But when you have dozens of microservices across hundreds of machines, you need:
- Scheduling — Which server should run which container?
- Health monitoring — What happens when a container crashes?
- Scaling — How do you add replicas when traffic spikes?
- Networking — How do services find and talk to each other?
- Rolling updates — How do you update without downtime?
- Storage — How do containers access persistent data?
Kubernetes solves all of these declaratively. You describe the desired state (e.g., “run 3 replicas of my API server on port 8080”), and Kubernetes continuously works to make the actual state match your description.
The Orchestra Conductor Analogy
An orchestra has many musicians (containers), each playing a different instrument (application). Without a conductor, they play at different tempos, miss cues, and produce chaos.
Kubernetes is the conductor:
- It tells each musician when to start and stop.
- It ensures the right number of violins (containers) are playing.
- If a musician gets sick (container crashes), the conductor brings in a substitute.
- When a new song (deployment) needs to be played, the conductor coordinates the transition.
- The conductor ensures everyone plays in harmony (networking, service discovery).
Docker builds the instruments; Kubernetes conducts the performance.
Core Concepts
Pod
The smallest deployable unit in Kubernetes. A pod wraps one or more containers that share storage and network. Usually you run one container per pod.
apiVersion: v1
kind: Pod
metadata:
name: my-app
spec:
containers:
- name: app
image: nginx:1.25
ports:
- containerPort: 80Node
A worker machine (physical or VM) in the cluster. Each node runs pods via the kubelet agent. Control plane components manage the cluster from the master nodes.
Cluster
A set of nodes grouped together. The control plane makes global decisions, and worker nodes run the actual workloads.
Deployment
A resource that declares the desired state for a set of pods. It handles rolling updates, rollbacks, and replica management.
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-server
spec:
replicas: 3
selector:
matchLabels:
app: api
template:
metadata:
labels:
app: api
spec:
containers:
- name: api
image: myapp/api:v2.1.0
ports:
- containerPort: 3000Service
An abstraction that exposes a set of pods as a network service. It provides a stable IP and DNS name, and load-balances traffic across pods.
apiVersion: v1
kind: Service
metadata:
name: api-service
spec:
selector:
app: api
ports:
- protocol: TCP
port: 80
targetPort: 3000
type: LoadBalancerHow Kubernetes Works
- You write YAML manifests describing your desired state.
kubectl apply -f manifest.yamlsends the manifest to the Kubernetes API server.- The control plane stores the desired state in etcd (distributed key-value store).
- The scheduler finds suitable nodes for each pod based on resource requirements.
- The kubelet on each node pulls container images and starts pods.
- The controller manager continuously monitors the cluster, ensuring actual state matches desired state.
Scaling and Self-Healing
Kubernetes scales automatically or on demand:
# Scale a deployment to 10 replicas
kubectl scale deployment api-server --replicas=10
# Or use Horizontal Pod Autoscaler (HPA) for automatic scaling
kubectl autoscale deployment api-server --min=3 --max=20 --cpu-percent=70Self-healing happens automatically: if a pod crashes, Kubernetes creates a replacement. If a node goes down, pods are rescheduled onto healthy nodes.
Kubernetes vs Docker
| Aspect | Docker | Kubernetes |
|---|---|---|
| Purpose | Build and run containers | Orchestrate containers across clusters |
| Scope | Single host | Multi-host cluster |
| Scaling | Manual via compose scale | Automatic, declarative |
| Self-healing | Restart policy only | Full health checks, rescheduling |
| Load balancing | Basic port mapping | Built-in Service + Ingress |
| Rolling updates | Manual or compose | Declarative with rollback |
| Secret management | Basic env vars | Native secrets + encryption |
Docker and Kubernetes are complementary. You use Docker to build and package your application, and Kubernetes to run and manage it at scale.
Managed Kubernetes (Cloud Providers)
| Provider | Service | Notes |
|---|---|---|
| AWS | EKS (Elastic Kubernetes Service) | Integrates with VPC, IAM, RDS |
| Azure | AKS (Azure Kubernetes Service) | Managed control plane, Azure AD |
| Google Cloud | GKE (Google Kubernetes Engine) | Google invented Kubernetes, fastest upgrades |
| DigitalOcean | DOKS | Simple, affordable managed K8s |
| IBM Cloud | IKS | Enterprise-focused |
Common Use Cases
Microservices deployment — Each microservice becomes a deployment and is exposed via a service. K8s handles routing, scaling, and health.
Batch processing — Run data processing jobs (Spark, Hadoop) on a Kubernetes cluster. Jobs run to completion and free resources automatically.
CI/CD runners — Run GitHub Actions self-hosted runners or GitLab runners on Kubernetes for elastic CI capacity.
Machine learning — ML training jobs run as Kubernetes Jobs with GPU resources, auto-scaled and checkpointed.
Stateful applications — Databases (PostgreSQL, Cassandra) run as StatefulSets with persistent volumes for stable storage.
FAQ
Related Terms
What is Docker — What is a Microservice — What is an API — What is CI/CD
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro