Self-healing

What happens when something crashes.

Beginner8 min · lesson 10 of 24
In plain terms
Self-healing is a night watchman who notices a bulb went out and replaces it before you wake up. A pod dies; Kubernetes quietly stands up a fresh one.
THE RECONCILE LOOP HEALS
1You declare 3copiesthe desired state,…2A pod diesa crash, or its whole…3Loop noticesthe gapactual count (2) no…4Replacementcreateda fresh pod appears,…
You set the desired count once; the loop keeps restoring it (only for controller-managed pods).

One of the biggest reasons to use Kubernetes: it repairs things while you sleep. You declared “three copies”; Kubernetes treats that as a promise it will defend against crashes, restarts, and dead machines.

terminal
$ kubectl get pods -l app=web
web-7d4b-x2f 1/1 Running
$ kubectl delete pod web-7d4b-x2f # simulate a crash
$ kubectl get pods -l app=web
web-7d4b-p9k 0/1 ContainerCreating # a replacement is already coming
web-7d4b-p9k 1/1 Running # ...and it is back, seconds later

Kill a pod and a fresh one appears in seconds. Lose a whole machine and its pods are recreated on other machines. You set the desired count once, and the reconcile loop keeps restoring it — no pager, no midnight fix.

Only for managed pods
Self-healing works for pods managed by a controller like a Deployment. A bare pod you created by hand is not defended — another reason to always use a Deployment.