DEV Community

Cover image for Kubectl Demystified: Mastering the `kubectl describe` Command
Kubernetes with Naveen
Kubernetes with Naveen

Posted on • Edited on

Kubectl Demystified: Mastering the `kubectl describe` Command

Kubernetes is a powerful container orchestration platform, but its complexity can make troubleshooting challenging. The kubectl describe command is a vital tool for understanding the state of your Kubernetes resources. This article explains what kubectl describe is, when to use it, and how to leverage it effectively, with practical examples for beginners and those preparing for the Certified Kubernetes Administrator (CKA) exam.

What is kubectl describe?

kubectl describe is a command-line tool that provides a detailed overview of Kubernetes resources, including their configuration, status, events, and relationships with other components. Unlike kubectl get, which offers a summarized view, kubectl describe compiles information from multiple sources to give you a comprehensive snapshot of a resource's lifecycle.

What Does kubectl describe Do?

When you run kubectl describe, it aggregates data such as:

  • Resource configuration: Labels, annotations, and metadata.
  • Status: Current state (e.g., Running, Pending, CrashLoopBackOff).
  • Events: A chronological list of actions and errors (e.g., failed image pulls, scheduling issues).
  • Dependencies: Related resources (e.g., pods managed by a deployment, endpoints for a service).

This command is particularly useful for debugging, as it highlights why a resource might not be functioning as expected.

When to Use kubectl describe

Use kubectl describe in the following scenarios:

  1. Troubleshooting: Diagnose why a pod isn’t starting, a service isn’t routing traffic, or a deployment is stuck.
  2. Inspecting State: Understand resource allocation (e.g., CPU/memory limits on a pod or node).
  3. Examining Events: Review warnings or errors (e.g., ImagePullBackOff, FailedScheduling).
  4. Preparing for the CKA Exam: Quickly identify issues in time-constrained scenarios.

Syntax and Basic Usage

kubectl describe <RESOURCE_TYPE> <RESOURCE_NAME>
# OR
kubectl describe <RESOURCE_TYPE>/<RESOURCE_NAME>
Enter fullscreen mode Exit fullscreen mode

Examples:

kubectl describe pod/nginx
kubectl describe deployment frontend -n staging # Specify a namespace
Enter fullscreen mode Exit fullscreen mode

Practical Examples with Explanations

1. Describing a Pod

Command:

kubectl describe pod myapp-pod
Enter fullscreen mode Exit fullscreen mode

Key Output Sections:

  • Containers: Shows container images, ports, and readiness/liveness probes.
  • Conditions: Ready, Initialized, ContainersReady.
  • Events: Critical for debugging (e.g., Failed to pull image "nginx:v3").

Use Case: A pod stuck in Pending state might show an event like Insufficient cpu/memory, indicating resource constraints on the node.

2. Describing a Deployment

Command:

kubectl describe deployment my-deployment
Enter fullscreen mode Exit fullscreen mode

Key Output:

  • Replicas: Desired, current, and updated replicas.
  • Strategy: Rolling update configuration.
  • Events: History of scaling operations or failed rollouts.

Use Case: If a deployment isn’t updating, check the Events section for errors in the new replica set.

3. Describing a Service

Command:

kubectl describe service my-service
Enter fullscreen mode Exit fullscreen mode

Key Output:

  • Selector: Labels used to target pods.
  • Endpoints: Pod IPs and ports included in the service.
  • Type: ClusterIP, NodePort, or LoadBalancer.

Use Case: If a service has no endpoints, its selector might not match any pods’ labels.

4. Describing a Node

Command:

kubectl describe node worker-node-1
Enter fullscreen mode Exit fullscreen mode

Key Output:

  • Capacity/Allocatable: Resources available on the node.
  • Conditions: MemoryPressure, DiskPressure, Ready.
  • Pods: List of pods running on the node.

Use Case: Identify why pods aren’t scheduled (e.g., node is out of resources or has taints).

Tips for the CKA Exam

  1. Debug Efficiently: Use kubectl describe to quickly spot issues in pods, deployments, or services without checking logs first.
  2. Focus on Events: The Events section often contains the root cause of problems (e.g., CrashLoopBackOff indicates a crashing container).
  3. Check Readiness Probes: Misconfigured probes can prevent pods from joining a service.
  4. Namespaces Matter: Always specify -n if the resource isn’t in the default namespace.

Common Errors to Look For

Error Likely Cause
ImagePullBackOff Invalid image name or missing permissions.
CrashLoopBackOff Application crashes on startup; check container logs.
FailedScheduling Insufficient node resources or taints blocking scheduling.
ErrImagePull Registry authentication issues or network problems.

Image description

Conclusion

kubectl describe is an indispensable tool for Kubernetes administrators. By providing a consolidated view of resource details and events, it simplifies debugging and accelerates problem resolution. For CKA candidates, mastering this command is essential for efficiently tackling exam scenarios. Practice using it across different resources to build confidence and fluency in Kubernetes operations.

Further Reading:

DevCycle image

Ship Faster, Stay Flexible.

DevCycle is the first feature flag platform with OpenFeature built-in to every open source SDK, designed to help developers ship faster while avoiding vendor-lock in.

Start shipping

Top comments (0)

👋 Kindness is contagious

Discover fresh viewpoints in this insightful post, supported by our vibrant DEV Community. Every developer’s experience matters—add your thoughts and help us grow together.

A simple “thank you” can uplift the author and spark new discussions—leave yours below!

On DEV, knowledge-sharing connects us and drives innovation. Found this useful? A quick note of appreciation makes a real impact.

Okay