image.png

Self healing means if a Pod or container crashes or goes red, Kubernetes automatically detects it and restarts or replaces it within seconds — without any manual action from you.

This is one of the biggest reasons Kubernetes is used in production.


How It Works

Kubernetes constantly watches the state of your cluster. You tell it "I want 3 pods running" and it makes sure that is always true. The moment reality doesn't match what you asked for, it fixes it.

You define replicas: 3
        ↓
All 3 pods running — healthy
        ↓
1 pod crashes / goes red
        ↓
Kubernetes detects mismatch (desired: 3, actual: 2)
        ↓
New pod automatically created within seconds
        ↓
Back to 3 pods running

What Triggers Self Healing

In all cases, as long as a Deployment or ReplicaSet is managing the pods, Kubernetes will bring them back.


Key Point — Replicas Matter Here

If you run a pod directly without a Deployment, self healing does not apply. The pod dies and stays dead.

Self healing only works when a Deployment or ReplicaSet is managing the pods — because they are the ones watching and maintaining the desired count.

# This pod has NO self healing — if it dies, it stays gone
kubectl run nginx --image=nginx

# This pod HAS self healing — Deployment watches and restores it
kubectl apply -f deployment.yml