Take a moment to think about this
A Deployment manages Pods indirectly, through a 'ReplicaSet' — you tell it 'I always want 3 pods running from this image' as the desired state, and the Deployment keeps that state maintained at all times. If one Pod crashes, the Deployment immediately creates a new one to fill in (so you're back to 3 out of 3). Updating a Deployment (say, to a new image version) also triggers an automatic rolling update (covered in a later chapter).
Let's connect this to a real scenario
Writing `replicas: 3` in a Deployment YAML keeps 3 pods running at all times. If you manually delete one pod with `kubectl delete pod`, you'll see the Deployment immediately create a replacement — a hands-on demo that proves the Deployment's self-healing power for yourself.
Let's look at it together
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-deployment
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: nginx:latest
ports:
- containerPort: 80$ kubectl apply -f deployment.yaml
deployment.apps/web-deployment created
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
web-deployment-7d9f8c6b5-abc12 1/1 Running 0 5s
web-deployment-7d9f8c6b5-def34 1/1 Running 0 5s
web-deployment-7d9f8c6b5-ghi56 1/1 Running 0 5s5-minute try-it
Apply the Deployment above and watch 3 pods running — then delete one with `kubectl delete pod <name>` and confirm it reappears on its own (self-healing).
A quick word of caution
Deleting a Deployment (`kubectl delete deployment`) takes down all the pods it controls too — if you only want to delete a single pod, target the pod directly (not the Deployment).