How to fix deployment not found in Kubernetes
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- Verify correct cluster and context
- Check if deployment exists in any namespace
- Set correct namespace for future commands
- Verify deployment name spelling
kubectl config current-contextkubectl cluster-infokubectl config get-contexts # List all available contextsdeployment 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
- 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
- Namespace doesn't exist or was deleted
- API group mismatch between creation and deletion (apps/v1 vs extensions/v1beta1)
- Deployed a Pod with kubectl run instead of creating an actual Deployment
- YAML manifest with syntax errors that failed validation during apply
- Deployment deleted by another user or automated cleanup
How to fix "deployment not found"
First, confirm you're connected to the right cluster:
kubectl config current-context
kubectl cluster-info
kubectl config get-contexts # List all available contextsIf wrong, switch context:
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
Search all namespaces:
kubectl get deployments --all-namespaces
kubectl get deploy -A | grep <deployment-name>If found in a different namespace, use -n flag:
kubectl get deployment <name> -n <found-namespace>If deployment isn't in any namespace, it was either never created or deleted.
If deployment is in a specific namespace, you can set it as default:
kubectl config set-context --current --namespace=<namespace>Now subsequent commands default to that namespace. Verify:
kubectl config current-context
kubectl get deployments # Should show deployments in your namespaceFor one-off commands, use -n flag: kubectl get deployment <name> -n <namespace>
Kubernetes names are case-sensitive. Confirm exact spelling:
kubectl get deployments -n <namespace> # Shows all deploymentsCompare 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.
If you used kubectl run, you may have created a Pod, not a Deployment:
kubectl get pods -n <namespace> | grep <name>To create an actual Deployment:
kubectl create deployment <name> --image=<image:tag>
# or from manifest:
kubectl apply -f deployment.yamlFor kubectl run to create a Deployment (instead of Pod), use --restart=Always (default in older versions): kubectl run <name> --image=<image:tag> --restart=Always
If deploying from a manifest, validate it:
kubectl apply -f deployment.yaml --dry-run=clientThis 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:
kubectl apply -f deployment.yamlIf namespace doesn't exist:
kubectl get namespacesCreate if missing:
kubectl create namespace <namespace-name>Then deploy to it:
kubectl apply -f deployment.yaml -n <namespace-name>Or set it in the manifest:
metadata:
name: myapp
namespace: myapp-ns # Explicitly set namespaceView recent changes:
kubectl describe namespace <namespace> # Shows recent events
kubectl get events -n <namespace> --sort-by='.lastTimestamp' # Recent eventsIf you deleted it accidentally, restore from backup or redeploy. If deleted by automated cleanup (e.g., CI/CD tear-down), reapply the manifest:
kubectl apply -f deployment.yamlFor easier management, install helper tools:
- kubectx: Switch between clusters
kubectx <context-name>- kubens: Switch between namespaces
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
- 📚Kubernetes Official Documentation
- 📖K8s: Deployments(Official Docs)
- 🐙K8s GitHub Issues(GitHub)
- 💬SO: K8s Deployments(Stack Overflow)