Kubernetes (K8s) is a powerful container orchestration tool. It helps us run, manage, scale, and heal containers automatically. But to really understand how Kubernetes works, we need to know about its main components and what they do.
Let’s break it down step-by-step.
What is Kubernetes Made Of?
Kubernetes is made of two major parts:
1. Control Plane (Master)
This is the brain of Kubernetes. It controls and manages the whole cluster.
- API Server
- The heart of Kubernetes.
- It receives all commands (like
kubectl apply
) and exposes Kubernetes to the outside world.
- Scheduler
- Decides where to run a new pod (on which node).
- It checks available resources and places the pod on a suitable worker node.
- ETCD
- The database of Kubernetes.
- It stores all cluster data in a key-value format. For example, details about pods, nodes, etc.
- Controller Manager
- Responsible for automatic actions like scaling, healing, and maintaining the desired state.
- For example, it makes sure the number of pods you define in a ReplicaSet is always running.
- Cloud Controller Manager (CCM)
Used when Kubernetes is running on a cloud provider (like AWS, GCP, Azure).
It helps Kubernetes communicate with the cloud environment.
It manages things like:
Node lifecycle in cloud (e.g., if a VM is deleted, remove the node from cluster).
Managing load balancers.
Attaching cloud storage volumes to pods. - If you’re using Kubernetes on a bare metal server, this component may not be active.
2. Data Plane / Worker Node
These are the servers where your containers actually run.
- Kubelet
- Talks to the control plane.
- Runs the pods on the node.
- Think of it like the worker that follows API server’s instructions.
- Kube-proxy
- Handles network communication between pods.
- It also does load balancing and assigns IP addresses.
- Container Runtime
- Responsible for running containers inside pods.
- Kubernetes supports many runtimes like Docker, Containerd, etc.
- Earlier, Docker used Dockershim as its runtime, but now Kubernetes mostly uses Containerd.
What is a Pod?
- In Kubernetes, the smallest unit of deployment is a Pod.
- A pod can have one or more containers.
- Kubernetes uses the Kubelet to run and manage pods on worker nodes.
In Docker, this job was done by the Docker Engine and Dockershim.
Cool Features of Kubernetes
- Auto Healing
- If a pod crashes, Kubernetes automatically restarts it or creates a new one.
- This is handled by the Controller Manager, and the API Server gets informed first.
- Auto Scaling
- Based on load, Kubernetes can increase or decrease the number of pods.
- This is managed by the Horizontal Pod Autoscaler and other controllers.
- Cluster-based Structure
- Kubernetes uses a master-worker setup.
- You never interact directly with worker nodes. All communication goes through the Control Plane.
Summary
Component | Role |
---|---|
API Server | Entry point of the cluster, handles requests |
Scheduler | Decides where pods will run |
ETCD | Stores all Kubernetes data |
Controller Manager | Maintains desired state (replicas, auto-healing) |
Kubelet | Runs pods on nodes |
Kube-proxy | Handles pod networking and load balancing |
Container Runtime | Runs containers inside pods (like Containerd, Docker) |