Full lesson
Explore the full explanation, examples, and visuals at your own pace.
What the developer sees
Your shop-api app has no Pods, and nothing looks broken. The first command finds no resources, and the Deployment shows 0/0 ready. Read that as ready over desired. Zero of zero means Kubernetes wasn't asked to run any copies at all, so nothing crashed.
kubectl get pods -l app=shop-api
kubectl get deployment shop-apiNo resources found in default namespace. NAME READY UP-TO-DATE AVAILABLE AGE shop-api 0/0 0 0 12d
Before: 3 replicas. After: 0
A Deployment, shop-api here, is Kubernetes' record of what you want running. Replicas are the copies of the Pod it should keep. It started at want 3, with 3 running. Then the count became 0, so the ReplicaSet removed every Pod to match. Nothing broke.
Two ways the count became zero
There are two ways shop-api could end up at zero. Someone ran kubectl scale with replicas equal to zero. Or deployment.yaml says replicas: zero, and someone applied it. Either way, Kubernetes didn't see a failure. It just received the number zero, and treated it as the new goal.
# Way 1: someone ran a command
kubectl scale deployment shop-api --replicas=0
# Way 2: the manifest says zero
# deployment.yaml
spec:
replicas: 0Why there are no errors
In a crash, the ReplicaSet keeps restarting Pods, and the failures show up as a Warning event, like BackOff. Scaling to zero is different. The ReplicaSet deletes all the Pods on purpose, and Kubernetes logs only a Normal scaled-down event. Nothing failed, so there's nothing to warn you about.
The file can reset it again
The file is a second source of truth. When deployment.yaml says replicas: 0, kubectl apply copies that onto shop-api, so it wants zero. The ReplicaSet matches that count, and the Pods go to none. A quick scale-up alone gets undone the next time someone applies the file.
The fix: live object and file
The fix has two parts. First, kubectl scale sets shop-api back to three replicas, so Pods return right away. Second, edit deployment.yaml so spec replicas says 3, then run kubectl apply. That changes the source of the number, so the next apply won't reset it to zero.
# 1. Bring Pods back now
kubectl scale deployment shop-api --replicas=3
# 2. Fix the source: deployment.yaml
spec:
replicas: 3
kubectl apply -f deployment.yamlBack to 3 Pods, and it stays
Now the file says replicas: 3. When kubectl apply sends that to shop-api, the Deployment wants three Pods again. It sets the count on the ReplicaSet, and the ReplicaSet creates Pods until they match. Once they're ready, kubectl get deployment reads 3/3, and the next apply won't undo it.
A Deployment keeps exactly the Pod count it's told, even zero.
A Deployment keeps exactly the Pod count it's told, even zero. So when shop-api showed 0/0, nothing had broken. It had been told to run nothing. Next time you see 0/0, check who or what set replicas, and fix that source, like deployment.yaml, not just the live object.