How to fix deployment not found in Kubernetes

KubernetesBEGINNERLOWUpdated Dec 6, 2025· 171 views

The "deployment not found" error occurs when kubectl cannot locate a Deployment resource. This is usually caused by a namespace mismatch, typo in the deployment name, connected to the wrong cluster, or the deployment was deleted.

Quick fix

Fixes deployment not found

kubectl config current-context
kubectl cluster-info
kubectl config get-contexts  # List all available contexts
  1. Verify correct cluster and context
  2. Check if deployment exists in any namespace
  3. Set correct namespace for future commands
  4. Verify deployment name spelling
kubernetes — error
kubectl config current-context
kubectl cluster-info
kubectl config get-contexts # List all available contexts
deployment not found

What this error means

When you run kubectl commands on a deployment and get "deployment not found", it means kubectl is looking in the wrong place or the deployment doesn't exist. Kubernetes resources are always scoped to a namespace (default is "default"), and a deployment in one namespace is invisible from another. Additionally, you must be connected to the correct Kubernetes cluster. This error is at the kubectl communication layer—it's not an application error, but rather kubectl or the API server can't find the resource you're asking about.

Typical symptoms

  • Error message: "Error from server (NotFound): deployments.apps "[name]" not found"
  • kubectl get deployments returns "No resources found in default namespace"
  • kubectl delete deployment fails with NotFound despite successful creation
  • CI/CD pipelines report deployment failures even though deployment status appears successful
  • GitLab Deploy Boards show "Kubernetes deployment not found" despite annotations being set
  • Other teams' deployments work fine, but your specific deployment is missing
  • Discrepancies between what kubectl reports and cluster state

Common causes

  1. Namespace mismatch: deployment created in "production" but querying "default" namespace
  2. Typo in deployment name or case sensitivity issues
  3. Connected to wrong Kubernetes cluster or context
  4. Namespace doesn't exist or was deleted
  5. API group mismatch between creation and deletion (apps/v1 vs extensions/v1beta1)
  6. Deployed a Pod with kubectl run instead of creating an actual Deployment
  7. YAML manifest with syntax errors that failed validation during apply
  8. Deployment deleted by another user or automated cleanup

How to fix "deployment not found"

1Verify correct cluster and context

First, confirm you're connected to the right cluster:

bash
kubectl config current-context
kubectl cluster-info
kubectl config get-contexts  # List all available contexts

If wrong, switch context:

bash
kubectl config use-context <correct-context-name>

For easier context switching, install kubectx: brew install kubectx or sudo git clone https://github.com/ahmetb/kubectx /opt/kubectx

2Check if deployment exists in any namespace

Search all namespaces:

bash
kubectl get deployments --all-namespaces
kubectl get deploy -A | grep <deployment-name>

If found in a different namespace, use -n flag:

bash
kubectl get deployment <name> -n <found-namespace>

If deployment isn't in any namespace, it was either never created or deleted.

3Set correct namespace for future commands

If deployment is in a specific namespace, you can set it as default:

bash
kubectl config set-context --current --namespace=<namespace>

Now subsequent commands default to that namespace. Verify:

bash
kubectl config current-context
kubectl get deployments  # Should show deployments in your namespace

For one-off commands, use -n flag: kubectl get deployment <name> -n <namespace>

4Verify deployment name spelling

Kubernetes names are case-sensitive. Confirm exact spelling:

bash
kubectl get deployments -n <namespace>  # Shows all deployments

Compare with your command. Common typos:
- "myapp" vs "my-app" (hyphen)
- "MyApp" vs "myapp" (case)
- "myapp-deploy" vs "myapp" (suffix)

If you're referencing it in code or scripts, check those strings match exactly.

5Check if you deployed a Pod instead of Deployment

If you used kubectl run, you may have created a Pod, not a Deployment:

bash
kubectl get pods -n <namespace> | grep <name>

To create an actual Deployment:

bash
kubectl create deployment <name> --image=<image:tag>
# or from manifest:
kubectl apply -f deployment.yaml

For kubectl run to create a Deployment (instead of Pod), use --restart=Always (default in older versions): kubectl run <name> --image=<image:tag> --restart=Always

6Validate YAML manifest syntax

If deploying from a manifest, validate it:

bash
kubectl apply -f deployment.yaml --dry-run=client

This shows validation errors without applying. Common issues:
- Incorrect indentation
- Wrong apiVersion (should be "apps/v1" for Deployments)
- Missing required fields (name, spec, containers)
- Invalid resource names (must start with letter, no special chars)

Fix errors and retry:

bash
kubectl apply -f deployment.yaml
7List available namespaces

If namespace doesn't exist:

bash
kubectl get namespaces

Create if missing:

bash
kubectl create namespace <namespace-name>

Then deploy to it:

bash
kubectl apply -f deployment.yaml -n <namespace-name>

Or set it in the manifest:

yaml
metadata:
  name: myapp
  namespace: myapp-ns  # Explicitly set namespace
8Check deployment history if recently deleted

View recent changes:

bash
kubectl describe namespace <namespace>  # Shows recent events
kubectl get events -n <namespace> --sort-by='.lastTimestamp'  # Recent events

If you deleted it accidentally, restore from backup or redeploy. If deleted by automated cleanup (e.g., CI/CD tear-down), reapply the manifest:

bash
kubectl apply -f deployment.yaml
9Use convenient tools for context and namespace switching

For easier management, install helper tools:
- kubectx: Switch between clusters

bash
kubectx <context-name>

- kubens: Switch between namespaces

bash
kubens <namespace>

These are faster than typing full kubectl commands. Find them at https://github.com/ahmetb/kubectx

Advanced notes

In multi-cluster setups, context confusion is very common—use kubectx/kubens to simplify switching. For GitOps deployments (ArgoCD, Flux), verify the namespace in the Application/HelmRelease resource matches your deployment namespace. In CI/CD pipelines, ensure the kubeconfig context points to the correct cluster; mismatches often occur during multi-environment deployments. When using kubectl from containers, ensure kubeconfig is mounted at the correct path: kubectl --kubeconfig=/path/to/config get deploy. For API group mismatches, use kubectl api-resources to verify the correct apiVersion. Some cloud providers use vendor-specific context naming conventions (e.g., AWS uses "arn:aws:eks:..." format).

Frequently asked questions

What does "deployment not found" mean?
When you run kubectl commands on a deployment and get "deployment not found", it means kubectl is looking in the wrong place or the deployment doesn't exist. Kubernetes resources are always scoped to a namespace (default is "default"), and a deployment in one namespace is invisible from another. Additionally, you must be connected to the correct Kubernetes cluster.
How do I fix "deployment not found"?
The "deployment not found" error occurs when kubectl cannot locate a Deployment resource. This is usually caused by a namespace mismatch, typo in the deployment name, connected to the wrong cluster, or the deployment was deleted.
What causes "deployment not found"?
Namespace mismatch: deployment created in "production" but querying "default" namespace Typo in deployment name or case sensitivity issues Connected to wrong Kubernetes cluster or context
Is the "deployment not found" error serious?
It is a low-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading