Kubernetes describe pod - Error from server NotFound
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
In the context of Kubernetes, dealing with issues related to pod status and configurations is an essential skill. One common issue you might encounter is when attempting to retrieve details about a pod using the kubectl describe pod command, only to be met with an error: Error from server (NotFound). Understanding why this error occurs and how to resolve it can greatly aid in the management of Kubernetes clusters.
Understanding the Error
The kubectl describe pod command is used to fetch detailed information about a specific pod, including its state, configuration parameters, container details, events, and more. When you receive an Error from server (NotFound), it typically indicates that the specified pod does not exist in the cluster. This could occur for several reasons, such as:
- Incorrect Namespace: Kubernetes is a namespace-oriented system, and resources are scoped within namespaces. If the pod resides in a different namespace than the current context, Kubernetes will not be able to find it.
- Typographical Error in Pod Name: There's a simple typographical error in the pod name which causes Kubernetes to search for a non-existent resource.
- Pod Terminated or Not Yet Created: The pod may have been terminated and removed from the system, or it might not have been created yet (due to pending deployment).
- Cluster Synchronization Issues: Sometimes, discrepancies can occur between what
kubectlis querying for and the current state of the cluster due to synchronization delays or cache issues.
Troubleshooting Steps
To address the Error from server (NotFound), you can follow these troubleshooting steps:
- Verify the Namespace: Ensure that you are querying the correct namespace. If your pod is in the
defaultnamespace, and your current context is set elsewhere, you'll need to specify the namespace explicitly using-n <namespace>. For example:
- Check Pod Availability: List all pods in the namespace to confirm the name:
Verify that the pod name is correct in the existing list of pods.
- Review Recent Events: If the pod was recently terminated, you can review the events to understand what happened to it:
- Deployment/Rollout Status: If the pod is part of a deployment, consider checking the deployment status:
This can give insights into why a pod might not have been created yet.
- Clear Cache (if applicable): If you're using a local
kubectlinstallation and suspect caching might be the issue, refreshing the cache might help. This isn't usually an issue but can occasionally occur.
Example
Consider a scenario where you're trying to describe a pod named nginx-pod-1234 in the production namespace but receive a not-found error. Here's a step-by-step investigation:
- Current Context Namespace:
Verify and switch to the correct namespace if needed:
- Verify Pod Existence:
Ensure nginx-pod-1234 is listed.
- Describe with Namespace:
If the pod appears, you might've initially been in the wrong namespace.
Common Commands
A quick reference table for common commands to resolve the NotFound error:
| Command | Description |
kubectl describe pod <pod-name> -n <namespace> | Fetch pod details within a specified namespace. |
kubectl get pods -n <namespace> | List all pods within a namespace to verify existence and name correctness. |
kubectl config set-context --current --namespace=<namespace> | Change the current namespace context. |
kubectl get events --sort-by=.metadata.creationTimestamp -n <namespace> | List recent events to diagnose pod state changes. |
kubectl rollout status deployment/<deployment-name> -n <namespace> | Check deployment status to ensure a pod is being created correctly. |
Understanding how to effectively troubleshoot and resolve the Error from server (NotFound) error in Kubernetes by confirming namespaces, checking for typographical errors, and verifying pod lifecycle events is essential for maintaining the health and efficiency of your cloud-native applications. By utilizing Kubernetes commands adeptly, one can ensure smoother operations and streamline Kubernetes management tasks.
Related reading
- Kubernetes dial tcp myIP10250 connect no route to host
- Kubernetes DNS intermittently failing with kube-dns service and CoreDNS pods seeming OK
- Kubernetes Docker Containers behind proxy
- Kubernetes Edit File In A Pod
- Kubernetes error when forwarding a port - Connection refused
- Kubernetes expired certificate
- Kubernetes Ephemeral Storage Limit and Container Logs
- Kubernetes equivalent of docker run --init

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.