Skip to content
Latchkey

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.

kubectl
error: deployments.apps "api" not found

Common 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.

Terminal
kubectl get deploy -A | grep <name>
kubectl config view --minify -o jsonpath='{..namespace}'

Target the correct name/namespace

  1. Pass -n <namespace> matching where the Deployment was created.
  2. Match the exact metadata.name from your manifest.
  3. 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →