0
0
KubernetesHow-ToBeginner · 3 min read

How to Use kubectl describe for Debugging Kubernetes Resources

Use kubectl describe followed by the resource type and name to get detailed information about Kubernetes objects. This command helps you see events, status, and configuration details useful for debugging issues in your cluster.
📐

Syntax

The basic syntax of kubectl describe is:

  • kubectl describe <resource-type> <resource-name>: Shows detailed info about a specific resource.
  • kubectl describe <resource-type>: Lists details for all resources of that type.
  • Common resource types include pod, service, deployment, and node.
bash
kubectl describe <resource-type> <resource-name>
💻

Example

This example shows how to describe a pod named nginx-pod to check its status and events for debugging.

bash
kubectl describe pod nginx-pod
Output
Name: nginx-pod Namespace: default Node: node-1/192.168.1.10 Start Time: Thu, 01 Jun 2023 10:00:00 +0000 Labels: app=nginx Status: Running IP: 10.244.1.5 Containers: nginx: Image: nginx:1.21 State: Running Ready: True Restart Count: 0 Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 10m default-scheduler Successfully assigned default/nginx-pod to node-1 Normal Pulled 9m kubelet Container image "nginx:1.21" already present on machine Normal Created 9m kubelet Created container nginx Normal Started 9m kubelet Started container nginx
⚠️

Common Pitfalls

Common mistakes when using kubectl describe include:

  • Using the wrong resource type or misspelling it, which causes errors.
  • Not specifying the resource name when required, leading to incomplete information.
  • Ignoring the Events section, which often contains clues about failures or restarts.

Always double-check resource names and focus on the events and status fields for debugging.

bash
kubectl describe podnginx-pod  # Wrong: no space between resource type and name
kubectl describe pod nginx-pod  # Correct
📊

Quick Reference

Tips for effective debugging with kubectl describe:

  • Use kubectl describe pod <pod-name> to check pod status and events.
  • Describe deployments or services to verify configuration and status.
  • Look for Events at the bottom for error messages or warnings.
  • Combine with kubectl get for a quick overview before detailed inspection.

Key Takeaways

Use kubectl describe with resource type and name to get detailed info for debugging.
Check the Events section for clues about errors or restarts.
Always verify resource names and types to avoid command errors.
Combine kubectl describe with kubectl get for efficient troubleshooting.