Full lesson
Explore the full explanation, examples, and visuals at your own pace.
CI deploy job
The pipeline is green, but shop-api 2.0 is crashing in production. Look at the output. The only real report from kubectl apply is the word configured. The job then printed its own success message, and nothing in this script checked whether a single new Pod actually started.
# deploy job
kubectl apply -f k8s/deployment.yaml
echo "Deploy succeeded"deployment.apps/shop-api configured Deploy succeeded
What kubectl apply actually confirms
Here's what actually happens. The CI job runs kubectl apply and sends manifest v2 to the API server. The server validates it and stores the new spec, so the shop-api Deployment now says image 2.0. Then it returns success. That's all apply confirms. No Pod has started yet.
One timeline: green before the crash
Here's the timeline, with illustrative times. The apply is accepted at four seconds, and the pipeline goes green at six. Only later do the v2 Pods start, at twenty seconds. By forty-five seconds they're in CrashLoopBackOff. Users may see errors by one thirty, if capacity drops or readiness probes are missing.
Who reports what, and when
Follow who talks to whom. The CI job sends the manifest to the API server, and the API server answers configured. That's the whole exchange, and CI goes green there. After that, the API server tells the controllers, they start v2 Pods on a node, and the node reports CrashLoopBackOff back to the API server, not to CI.
Fix: wait for the rollout
The fix is one extra line after apply. kubectl rollout status watches the shop-api rollout until the updated replicas are available. If that doesn't happen within 120 seconds, it exits non-zero, and the job fails. Just pick a timeout shorter than your CI job's own limit.
# deploy job
kubectl apply -f k8s/deployment.yaml
kubectl rollout status deployment/shop-api \
--timeout=120sSame crash, honest pipeline
Take the same broken 2.0 rollout. With apply only, the change is accepted, the command exits 0, and the pipeline goes green. The Pods crash afterward. With apply plus rollout status, the job waits and watches those Pods crash. After 120 seconds it times out, and the pipeline goes red.
What rollout status can trust
Rollout status is only as honest as your readiness probes. Without one, a running container counts as ready. And when the timeout hits, it fails the job, not the rollout. Kubernetes keeps the half-finished update, so rollback is a separate decision.
- It counts Pods as available via readiness
- No readiness probe: running looks ready
- Timeout fails the job, not the rollout
Accepted and working are two different moments.
Kubernetes accepting a change and your Pods actually working are two separate moments. Apply gets accepted at four seconds, but with a rollout wait, green arrives only once the v2 Pods are Ready. So make green mean healthy Pods, never just that apply succeeded.