0
0
KubernetesHow-ToBeginner · 3 min read

How to Describe a Pod in Kubernetes Using kubectl

Use the kubectl describe pod [pod-name] command to get detailed information about a Kubernetes pod, including its status, container details, and events. This command helps you understand the pod's current state and troubleshoot issues.
📐

Syntax

The basic syntax to describe a pod in Kubernetes is:

  • kubectl describe pod [pod-name] - Shows detailed info about the specified pod.
  • --namespace [namespace] - Optional flag to specify the namespace if the pod is not in the default namespace.
bash
kubectl describe pod [pod-name] [--namespace namespace]
💻

Example

This example shows how to describe a pod named nginx-pod in the default namespace. It displays the pod's status, container info, IP address, and recent events.

bash
kubectl describe pod nginx-pod
Output
Name: nginx-pod Namespace: default Priority: 0 Node: node-1/192.168.1.10 Start Time: Thu, 01 Jun 2023 10:00:00 +0000 Labels: app=nginx Annotations: <none> Status: Running IP: 10.244.1.5 Containers: nginx: Container ID: docker://abcdef123456 Image: nginx:1.21 Image ID: docker-pullable://nginx@sha256:... Port: 80/TCP State: Running Started: Thu, 01 Jun 2023 10:01:00 +0000 Ready: True Restart Count: 0 Conditions: Type Status Initialized True Ready True ContainersReady True PodScheduled True Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 5m default-scheduler Successfully assigned default/nginx-pod to node-1 Normal Pulled 4m kubelet Container image "nginx:1.21" already present on machine Normal Created 4m kubelet Created container nginx Normal Started 4m kubelet Started container nginx
⚠️

Common Pitfalls

Common mistakes when describing pods include:

  • Using the wrong pod name or misspelling it, which causes an error like Error from server (NotFound): pods "wrong-name" not found.
  • Not specifying the correct namespace if the pod is in a namespace other than default. Use --namespace flag to fix this.
  • Expecting kubectl describe pod to show logs; it shows status and events but not container logs. Use kubectl logs [pod-name] for logs.
bash
kubectl describe pod wrong-pod-name
# Error from server (NotFound): pods "wrong-pod-name" not found

kubectl describe pod nginx-pod --namespace custom-namespace
# Correctly describes pod in 'custom-namespace'
📊

Quick Reference

Tips for using kubectl describe pod:

  • Always verify the pod name with kubectl get pods.
  • Use --namespace if your pod is not in the default namespace.
  • Check the Events section at the bottom for recent pod activity and errors.
  • Combine with kubectl get pods -o wide for a quick overview before describing.

Key Takeaways

Use kubectl describe pod [pod-name] to get detailed pod information including status and events.
Specify the correct namespace with --namespace if the pod is not in the default namespace.
Check the Events section in the output to understand recent pod activities and troubleshoot issues.
Describing a pod does not show logs; use kubectl logs [pod-name] for container logs.
Verify pod names with kubectl get pods to avoid errors.