Kubernetes is not a command runner. It keeps comparing what you asked for with what exists, and fixes the gap. Here is the loop, piece by piece.
You tell Kubernetes, "I want three copies of my app running." Then you stop one on purpose, and a new one appears. Nobody pressed a button.
Here is the key idea. Kubernetes does not just run commands. It keeps comparing what you asked for with what is actually happening, and fixes any gap, again and again. Once you see that, the rest is just names.
Say your app runs in a container (a sealed box holding your app and everything it needs). One container on one machine is easy. Now run 50 of them across 10 machines, and one crashes at 3 a.m.
The official docs say it plainly: "if a container goes down, another container needs to start." Kubernetes (Greek for "helmsman or pilot") is the system that does that job for you.
So how does it know something went wrong? It keeps two notes.
The desired state is what you want. The actual state is what exists right now. Kubernetes keeps both written down and works to close the difference.
You write the desired state in a file (the spec). Kubernetes keeps the current state next to it. You never say "start a copy." You say "I want 3," and it works out the rest.
You describe the goal, not the steps. Next, who does the fixing?
The docs use a room thermostat as the example. You set 24 degrees (desired). The room is 28 (actual). The thermostat switches the cooling on until they match, then switches it off. A controller is like that thermostat, for your cluster.
It never finishes. The docs even say your cluster "potentially never reaches a stable state," and that is fine as long as the controllers keep running.
So what are these controllers, and where do they live?
A cluster is a group of machines. Each machine is a node. One part is the "brain" (the control plane), and the rest do the work.
| Piece | What the docs say it does |
|---|---|
| API server | The front end of the control plane. Everything talks to it. |
| etcd | A consistent, highly-available key value store holding all cluster data. |
| Scheduler | Watches for new Pods with no node and picks one for them. |
| Controller manager | Runs the controller processes. |
| Kubelet | Agent on each node. Makes sure the containers in its Pods are running and healthy. |
Think of etcd as the one notebook everyone agrees is the truth. Only the API server writes to it. The other parts ask the API server.
Now what are the "Pods" in the diagram?
A Pod is "the smallest deployable unit" in Kubernetes: one or more containers sharing storage and network. Usually it is one container in one Pod.
Pods are disposable. The docs say you will "rarely create individual Pods directly" because Pods are "relatively ephemeral, disposable entities." If a node fails, the Pod is gone. So you put something in charge of Pods.
A Deployment is the thermostat for Pods. You ask for "3 copies of nginx." It makes a ReplicaSet, which makes the Pods. When you update the app, it slowly swaps old Pods for new ones.
Now let's follow one Deployment all the way down. Click Next and watch which piece lights up.
You send the Deployment to the API server, and it is saved in etcd
Look at the last step. Nothing starts over. The same loop just runs again.
Pods come and go, and each new one gets a new IP address (its network address). So how does anyone find your app? Imagine a shop that changes its street address every week.
A Service is the fix. The docs call it a way to expose an app running as one or more Pods. It picks Pods by their labels (name tags), so the set can change and the Service still finds them. Each node also runs kube-proxy (the docs say some network plugins do this job themselves) to make Services work on the network.
You need a cluster. minikube or kind gives you one on a laptop. These commands are from the official Deployment docs:
kubectl apply -f https://k8s.io/examples/controllers/nginx-deployment.yaml
kubectl get deployments
kubectl scale deployment/nginx-deployment --replicas=10
kubectl get pods
Now delete one Pod with kubectl delete pod <name> and run kubectl get pods again. A new one shows up. That is the loop doing its job.
kubectl describe pod and read the events. They show what the scheduler and kubelet did.