Full lesson
Explore the full explanation, examples, and visuals at your own pace.
Terminal
You delete a crashing Pod, and seconds later a new one appears with a different name. It crashes too. Pod abc12 is gone, but xk4p2 is already in CrashLoopBackOff. Something owns these Pods, and it recreated the Pod the moment you removed it.
$ kubectl get pods
NAME STATUS RESTARTS
checkout-7d9f8-abc12 CrashLoopBackOff 5
$ kubectl delete pod checkout-7d9f8-abc12
pod "checkout-7d9f8-abc12" deleted
$ kubectl get pods
NAME STATUS RESTARTS
checkout-7d9f8-xk4p2 CrashLoopBackOff 1Desired: 3 replicas
Your Deployment, checkout, doesn't run Pods directly. It owns a ReplicaSet, and that ReplicaSet has one job: keep exactly three Pods alive. Those Pods, like abc12, are disposable instances. The ReplicaSet manages them, and it can replace any of them whenever the count drops.
Actual 2, desired 3
You run kubectl delete pod, and the API Server removes it. Now the ReplicaSet controller sees two Pods against a desired three. It asks the API Server to create a new one from the template, and the Kubelet starts it. Then the container crashes again, within seconds.
deployment.yaml (Pod template)
Look at the Pod template. It pins the image shop/checkout:1.4, sets DB_HOST to db-old, and caps memory at 256Mi. Every replacement Pod is stamped from this. So if db-old is unreachable, each new Pod inherits that same failure and exits on startup.
apiVersion: apps/v1
kind: Deployment
metadata:
name: checkout
spec:
replicas: 3
# selector and labels omitted
template:
spec:
containers:
- name: checkout
image: shop/checkout:1.4
env:
- name: DB_HOST
value: db-old
resources:
limits:
memory: 256MiSame template, same bug
Deleting abc12 removed one copy. It didn't touch the template. So the Pod Template stamps out xk4p2, with the same settings, and it exits with code 1 just like the first one.
Deleting a Pod erases one copy; the template prints another.
Two different recoveries
Kubernetes has two separate recoveries. When a container crashes, the kubelet restarts it inside the same Pod, so the name stays and RESTARTS climbs with growing backoff. When you delete the Pod, the ReplicaSet creates a new one, with a new name and a zero count. Both reuse the same spec.
All three checkout Pods crash with exit code one on three different nodes. Will deleting them fix it?
All three checkout Pods crash with exit code one on three different nodes. Will deleting them fix it?
- Yes, fresh Pods start with a clean slate
- No, replacements use the same broken template
- Yes, if you delete all three at once
All three checkout Pods crash with exit code one on three different nodes. Will deleting them fix it?
No, replacements use the same broken template. Every replacement is stamped from the same Pod template, with the same image and the same DB_HOST value. Crashes across different nodes point to the spec or a dependency, not one bad instance. Deleting all three just makes the ReplicaSet create three new copies of the same bug.
- Yes, fresh Pods start with a clean slate
- No, replacements use the same broken template
- Yes, if you delete all three at once
Does deleting the Pod help?
Deleting a Pod helps when the fault belongs to that instance, like a bad node or stuck state. It won't help when the cause is in the template, or outside it, like db-old being unreachable.
- Helps: fault tied to one node or instance
- No: bug in image or Pod spec
- No: dependency down, like the database
Instance or spec-wide?
Look at the NODE column. All three Pods are crashing, on node-a, node-b, and node-c. Different machines, same failure, so the cause is spec-wide. One bad Pod on one node would point at the instance. Describe adds the detail: exit code 1, then back-off restarting.
$ kubectl get pods -o wide # columns trimmed
NAME STATUS RESTARTS NODE
checkout-7d9f8-xk4p2 CrashLoopBackOff 3 node-a
checkout-7d9f8-m2q8z CrashLoopBackOff 6 node-b
checkout-7d9f8-r7t1c CrashLoopBackOff 6 node-c
$ kubectl describe pod checkout-7d9f8-xk4p2
Last State: Terminated
Reason: Error
Exit Code: 1
Events: Back-off restarting failed containerFix the source, not the copy
Real fixes go upstream. Edit DB_HOST in the Deployment spec, or use rollout undo to return to a working revision. Either way, the Deployment rolls out new Pods from a better template. Scaling only changes how many copies run. And if the database is the problem, fix that.
Change the template, not the copy
Deleting a Pod erases one copy; the template prints another. So before you delete anything, run kubectl get pods -o wide. If every Pod crashes the same way, the cause lives in the spec, so change the template, not the copy.




