Kubernetes and Cloud Native Associate (KCNA)Kubernetes FundamentalsMedium
A DevOps engineer is troubleshooting a Pod that is exhibiting unexpected behavior. They need to get a detailed view of the Pod's current state, including events, conditions, and resource usage. Which `kubectl` command would provide this comprehensive information?
- A`kubectl logs my-pod`
- B`kubectl describe pod my-pod`
- C`kubectl get pod my-pod`
- D`kubectl exec -it my-pod -- bash`
Show answer & explanationAnswer & explanation
Correct answer: B. `kubectl describe pod my-pod`
The `kubectl describe` command provides a detailed summary of a specific Kubernetes resource, including its current state, events, conditions, and associated resources, making it ideal for troubleshooting and gaining comprehensive insights.
Why the other options are wrong
- A. `kubectl logs` retrieves the logs from containers within a Pod, not the Pod's overall state or events.
- C. `kubectl get` provides a high-level summary of resources, not detailed events or conditions.
- D. `kubectl exec` allows you to execute commands inside a running container, which is useful for direct interaction but not for viewing the Pod's descriptive state.
kubectl describe
A `kubectl` command used to fetch detailed information about a specific Kubernetes resource, including its current status, events, and related objects.
- Provides a comprehensive summary for troubleshooting.
- Shows events, conditions, and resource specifications.
- Useful for understanding why a resource is not behaving as expected.
Memory trick: Describe tells you the 'whole story' of a resource.