Full lesson
Explore the full explanation, examples, and visuals at your own pace.
deploy.yaml, then the terminal
You renamed your Deployment, and now you have two. Look at what apply printed: created, not configured. That means Kubernetes treated frontend as something brand new. Then kubectl get deployments lists both, frontend at twenty seconds old, and web still running at five days, with its own Pods.
# deploy.yaml
metadata:
name: frontend # was: web
$ kubectl apply -f deploy.yaml
deployment.apps/frontend created
$ kubectl get deployments
NAME READY AGE
frontend 3/3 20s
web 3/3 5dSame file, new name, new Deployment
Before the change, one Deployment, web, runs three Pods. After apply, there are two. Kubernetes identifies objects by name. Nothing called frontend existed, so it created a new one. And since the file no longer mentions web, Kubernetes never touches it. It just keeps running.
Fix: remove the old one once the new one is ready
First, check that frontend is healthy. Three out of three ready means all its Pods are running. Pods are the running copies of your app. Once that's true, delete web. Deleting a Deployment also removes its Pods, so the old copies go away and only frontend remains.
$ kubectl get deployment frontend
NAME READY AGE
frontend 3/3 1m
$ kubectl delete deployment web
deployment.apps "web" deletedA new name isn't a rename. It's a new thing.
A new name isn't a rename. It's a new thing. Kubernetes tracks objects by name, so after changing one, always delete the old object yourself.
