Full lesson
Explore the full explanation, examples, and visuals at your own pace.
terminal
You deleted your Pod. It never came back. We started it with kubectl run, which made a Pod, a running copy of your container. Then we deleted it, and kubectl get pods says no resources found. The empty output means your app is gone.
$ kubectl run web --image=nginx
pod/web created
$ kubectl delete pod web
pod "web" deleted
$ kubectl get pods
No resources found in default namespace.Same delete, different outcome
Both sides get the same delete, but only one comes back. The lone Pod was made by kubectl run, and nothing watches it, so it just disappears. A Deployment is a manager holding a target Pod count. It notices one is missing and creates a replacement.
The fix: run apps with a Deployment
We create a Deployment instead, then delete the Pod it made. That Pod name is generated, and these names are illustrative. Now look at kubectl get pods. A new Pod with a different name is already running, only three seconds old. The Deployment wanted one Pod, found zero, and created a replacement.
$ kubectl create deployment web --image=nginx
deployment.apps/web created
$ kubectl delete pod web-5d8f7c9b6-x2k4p
pod "web-5d8f7c9b6-x2k4p" deleted
$ kubectl get pods
NAME READY STATUS AGE
web-5d8f7c9b6-q7m9z 1/1 Running 3sA Pod on its own has no one to bring it back.
A Pod on its own has no one to bring it back. So for anything you expect to keep running, use a Deployment.
