Programming
We provide developers and engineers the guides and tutorials they...
Search
We provide developers and engineers the guides and tutorials they...
Content is king. It's not just about how you're going to write, b...
Looking for an engaging connection with thousands of other people...
What Kubernetes does: scheduling containers across machines, self-healing, scaling and rollouts. Pods, deployments, services and the control plane explained.
Quick answer: Kubernetes is a system for running containers across a group of machines. You tell it what you want, for example "run five copies of this container and expose them on port 443", and it works continuously to make that true. It decides which machine each container runs on, restarts containers that crash, replaces ones on failed machines, spreads network traffic across healthy copies, scales the number up and down, and rolls out new versions without downtime. Companies use it because it gives them one consistent, automated way to operate hundreds of services on any cloud or their own hardware.
Also Read: How CI/CD Pipelines Work: From Commit to Production - Tooling
Running one container on one server is simple. Running hundreds of containers across dozens of servers raises questions immediately:
Doing this by hand, or with home-made scripts, does not scale. A container orchestrator automates it. Kubernetes, released by Google in 2014 and drawing on its experience running containers internally, became the standard. It is now maintained by the Cloud Native Computing Foundation. The name is often shortened to K8s.
Traditional operations are imperative: "start this container on that server". Kubernetes is declarative. You describe the end result in a file, and Kubernetes makes it happen and keeps it that way.
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 3
selector:
matchLabels: { app: web }
template:
metadata:
labels: { app: web }
spec:
containers:
- name: web
image: registry.example.com/web:1.4.2
ports:
- containerPort: 8080
resources:
requests: { cpu: "250m", memory: "256Mi" }
This says: three copies of this image should always be running. If one dies, Kubernetes starts another. If you change replicas to 10, it starts seven more. If you change the image tag, it rolls out the new version.
Underneath is a reconciliation loop: small programs called controllers constantly compare the desired state with the actual state and act to close any gap. A thermostat is the usual analogy. You set the temperature; it does whatever is needed to reach and hold it.
| Object | What it is |
|---|---|
| Pod | The smallest unit: one or more containers that run together, share a network address and can share storage. Pods are disposable |
| Deployment | Manages a set of identical pods: how many, which version, how to update |
| Service | A stable name and virtual IP address in front of a changing set of pods, with load balancing between them |
| Ingress / Gateway | Routes HTTP traffic from outside the cluster to services, by hostname and path |
| ConfigMap and Secret | Configuration and sensitive values, kept separate from the image |
| Namespace | A way to divide a cluster between teams or environments |
| StatefulSet | Like a Deployment, for workloads that need stable identities and storage, such as databases |
| DaemonSet | Runs one pod on every node, for things like log collectors |
| Job / CronJob | Runs a task to completion, once or on a schedule |
| PersistentVolume | Storage that outlives any individual pod |
Pods are deliberately temporary. They come and go, and their IP addresses change. That is why you never address a pod directly. You address a Service, which always points at whichever healthy pods currently match its label selector.
A cluster has two parts, described in the Kubernetes architecture documentation.
| Component | Job |
|---|---|
| API server | The front door. Every command and every component talks to it |
| etcd | A consistent, replicated key-value store holding all cluster state. It uses the Raft algorithm; see how consensus algorithms work |
| Scheduler | Chooses a node for each new pod, based on available resources and constraints |
| Controller manager | Runs the reconciliation loops |
| Component | Job |
|---|---|
| kubelet | An agent on every node that starts and monitors the containers assigned to it |
| Container runtime | Actually runs containers (commonly containerd) |
| kube-proxy / network plugin | Sets up networking so services and pods can reach each other |
kubectl apply.Health checks deserve a mention. A liveness probe tells Kubernetes when to restart a container. A readiness probe tells it when a container can receive traffic. A startup probe covers slow-starting applications.
Kubernetes is powerful and it is complex.
Managed services such as Amazon EKS, Google GKE and Azure AKS run the control plane for you, which removes much of the burden but not all of it.
| Your situation | Probably better |
|---|---|
| One application, a small team | A platform-as-a-service, or a managed container service |
| Occasional or event-driven workloads | Serverless; see what serverless really means |
| A handful of containers on one server | Docker Compose |
| Many services, several teams, a need for consistency and portability | Kubernetes |
A common mistake is adopting Kubernetes before having the problems it solves. It pays off when you have many services and a team able to run the platform.
A system that automatically runs and manages containers across many machines, keeping the number and version you asked for running at all times.
Docker builds and runs containers on a single machine. Kubernetes coordinates containers across a cluster of machines.
The smallest deployable unit in Kubernetes: one or more containers that share a network address and are scheduled together.
No, but its complexity is easier to justify at scale. Small teams are often better served by simpler managed platforms.
Kubernetes turns a group of machines into a single platform that you program with declarations: say what should be running, and controllers keep it running. That brings self-healing, scaling and safe rollouts as standard. The price is real complexity, so the question is not whether Kubernetes is good, but whether your situation has reached the point where it is worth it.