Kubernetes "kubectl rollout: deployment not found" in CI - Fix it
A kubectl rollout status/restart ran against a Deployment name + namespace that does not exist. Either the apply that creates it has not run, the name differs, or you are pointed at the wrong namespace/context.
What this error means
kubectl rollout status deployment/<name> fails with Error from server (NotFound): deployments.apps "<name>" not found. The deploy/apply step may have succeeded under a different name or namespace.
error: deployments.apps "api" not foundCommon causes
Name or namespace mismatch
The rollout command uses a different name (or default namespace) than where the Deployment was actually created.
Apply step did not create it
A prior kubectl apply failed or created a different kind/name, so the Deployment the rollout waits on was never made.
How to fix it
List what actually exists
Confirm the real name and namespace before waiting on a rollout.
kubectl get deploy -A | grep <name>
kubectl config view --minify -o jsonpath='{..namespace}'Target the correct name/namespace
- Pass
-n <namespace>matching where the Deployment was created. - Match the exact metadata.name from your manifest.
- Ensure the apply step runs (and succeeds) before the rollout-status step.
How to prevent it
- Set the namespace explicitly in every kubectl call in CI.
- Use the same name variable for apply and rollout status.
- Fail the pipeline if apply did not create the expected resource.