Full lesson
Explore the full explanation, examples, and visuals at your own pace.
deploy-check.sh
Your script worked yesterday. Today the Pod name is different. The command asks for web-7d9f8c6b5-x2k4p, a name typed in by hand. After the redeploy, no Pod has that name, so Kubernetes answers with a NotFound error.
kubectl logs web-7d9f8c6b5-x2k4p
# after redeploy:
Error from server (NotFound): pods "web-7d9f8c6b5-x2k4p" not foundSame Deployment, new Pod name, same label
A Deployment is the controller that manages your Pods. On redeploy, it replaces the old Pod with a new one, and Kubernetes generates a fresh name. But look at the label tag, a key-value sticker. It's still app: web, on both Pods.
Select by label, not by name
Instead of a name, ask for the label. The command kubectl get pods with dash l app equals web returns whichever Pods carry that label right now. You can also run kubectl logs deployment/web, but that shows logs from just one of its Pods, not all.
# find the current Pods by label
kubectl get pods -l app=web
# or read logs through the Deployment
kubectl logs deployment/webNames change every deploy. Labels don't.
Names change every deploy. Labels don't. So replace hardcoded Pod names in your scripts with label selectors, like app equals web.
