By Sailee Shingare | M.S. in Computer Science, Northern Illinois University (NIU)
In the last post, we learned how Docker lets you package and run applications in containers.
But here’s a question — what happens when you have not one container, but hundreds?
What if a container crashes at 3 AM? What if traffic spikes and you need 50 containers instead of 5? Who manages all of that?
That’s exactly what Kubernetes does.
What is Kubernetes?
Kubernetes (also written as K8s) is an open-source container orchestration platform. It automates the deployment, scaling, and management of containerized applications.
In simple terms — Docker runs containers, Kubernetes manages them at scale.
Google originally built Kubernetes based on their internal system for managing billions of containers. They open-sourced it in 2014 and it quickly became the industry standard.
Today, if you run containers in production — you almost certainly use Kubernetes.
Why Do You Need Kubernetes?
Imagine you’re running a food delivery app with three containers:
- Container 1: Frontend
- Container 2: Backend API
- Container 3: Database
On a normal day that’s fine. But on New Year’s Eve, traffic spikes 10x. You need 50 backend containers instead of 5. One container crashes. Another runs out of memory.
Without Kubernetes, you’d have to:
- Manually start new containers
- Manually restart crashed ones
- Manually balance traffic across them
- Stay up all night monitoring everything
- With Kubernetes, all of this happens automatically.
Key Kubernetes Concepts
Cluster A set of machines (called nodes) that run your containers. Every Kubernetes setup has at least one cluster.
Node A single machine inside a cluster. Can be a physical server or a virtual machine. Nodes are where your containers actually run.
Pod The smallest unit in Kubernetes. A pod wraps one or more containers that work together. Think of a pod as a container’s home inside Kubernetes.
Deployment Tells Kubernetes how many copies (replicas) of your pod to run and how to update them. If a pod crashes, the deployment automatically creates a new one.
Service Exposes your pods to the network. Since pods are temporary and their IP addresses change, a service provides a stable endpoint to reach them.
Namespace A way to divide a cluster into separate virtual environments. Useful for separating development, staging, and production workloads.
How Kubernetes Works
Kubernetes has two main components:
Control Plane (Master) The brain of Kubernetes. It makes decisions about the cluster — scheduling pods, detecting failures, scaling applications.
Worker Nodes The muscle of Kubernetes. This is where your actual containers run.
Here’s the simple flow:
You tell Kubernetes what you want → Kubernetes figures out how to make it
happen → Kubernetes keeps it that way automatically
This is called the declarative model — you describe the desired state, Kubernetes handles the rest.
A Simple Kubernetes Example
Here’s what a basic deployment looks like in Kubernetes:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 3 # Run 3 copies of my container
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: my-app:1.0 # Docker image to use
ports:
- containerPort: 8080
This tells Kubernetes:
- Run 3 copies of my container
- Use the Docker image my-app:1.0
- Expose port 8080
If any of those 3 containers crash, Kubernetes automatically starts a replacement. If you update the image, Kubernetes rolls out the update without any downtime.
Key Features of Kubernetes
Auto-scaling Automatically add or remove containers based on traffic or CPU usage. Traffic spikes? Kubernetes scales up. Traffic drops? It scales back down.
Self-healing If a container crashes, Kubernetes restarts it automatically. If a node fails, Kubernetes moves its workloads to healthy nodes.
Rolling updates Update your application with zero downtime. Kubernetes gradually replaces old containers with new ones, ensuring your app stays available throughout.
Load balancing Automatically distributes traffic across all running containers so no single container gets overwhelmed.
Storage management Automatically mounts storage — whether from local disk, AWS EBS, or Azure Disk — to your containers.
Kubernetes in the Cloud
Every major cloud provider offers a managed Kubernetes service:
- AWS — Amazon EKS (Elastic Kubernetes Service)
- Azure — AKS (Azure Kubernetes Service)
- Google Cloud — GKE (Google Kubernetes Engine)
With managed Kubernetes, the cloud provider handles the control plane for you. You just deploy your applications and let Kubernetes manage them.
Docker vs Kubernetes — The Simple Distinction
A common confusion for beginners:
Docker builds and runs individual containers. Kubernetes manages many containers across many machines.
They work together, not against each other. You build your container with Docker, then deploy and manage it with Kubernetes.
Try it Yourself
The easiest way to try Kubernetes locally is Minikube — it runs a single-node Kubernetes cluster on your laptop.
- Install Minikube at minikube.sigs.k8s.io
- Install kubectl — the command line tool for Kubernetes
- Start a cluster:
minikube start
- Deploy a simple app:
kubectl create deployment hello-k8s --image=nginx
kubectl expose deployment hello-k8s --port=80 --type=NodePort
minikube service hello-k8s
Your browser will open with an Nginx welcome page — running inside Kubernetes on your laptop.
What’s Next?
Now you understand containers (Docker) and container management (Kubernetes). But how does your code actually get packaged into a container and deployed automatically every time you make a change?
That’s CI/CD — Continuous Integration and Continuous Deployment. We’ll cover that in the next post.
Top comments (0)