Kubernetes and Cloud Native Associate (KCNA)Kubernetes FundamentalsEasy
A cluster administrator needs to inspect the current configuration of the 'nginx-deployment' Deployment in the 'default' namespace, including its labels, selectors, and container images. Which `kubectl` command should the administrator use?
- A`kubectl get deployment nginx-deployment`
- B`kubectl exec -it nginx-deployment -- cat /etc/kubernetes/config`
- C`kubectl describe deployment nginx-deployment`
- D`kubectl logs deployment/nginx-deployment`
Show answer & explanationAnswer & explanation
Correct answer: C. `kubectl describe deployment nginx-deployment`
The `kubectl describe` command provides a detailed view of a specific resource, including its current state, events, and related objects like Pods and ReplicaSets, which is ideal for inspecting configuration details.
Why the other options are wrong
- A. `kubectl get` provides a high-level summary but not the detailed configuration requested.
- B. `kubectl exec` is used to run commands inside a container, not to inspect a Kubernetes resource's configuration.
- D. `kubectl logs` is used to retrieve logs from a running Pod, not to inspect a Deployment's configuration.
`kubectl describe`
A `kubectl` command used to show detailed information about a specific Kubernetes resource, including its current state, events, and related objects.
- Provides a comprehensive overview.
- Includes events, labels, selectors, and status.
- Useful for debugging and understanding resource configurations.
Memory trick: Get for General, Describe for Details, Logs for Living history, Exec for Entry.