Kubernetes Administration Question
Which of these commands is used to retrieve the documentation and field definitions for a Kubernetes resource?
kubectl explain
kubectl api-resources
kubectl get --help
kubectl show
Resolution & Explanations
The kubectl explain command is used to retrieve documentation and field definitions for Kubernetes resources. It provides detailed information about resource types, including their API version, kind, and a description of each field.
How it Works
kubectl explain queries the Kubernetes API server for the OpenAPI schema of a resource and displays human-readable documentation. For example, kubectl explain pods shows the top-level fields of a Pod, and kubectl explain pods.spec.containers drills down into nested fields.
Why the Correct Answer is Right
kubectl explain is specifically designed to fetch documentation and field definitions for any Kubernetes resource. It is the standard tool for understanding resource structure without needing to consult external documentation.
Why the Incorrect Answers are Wrong
kubectl api-resourceslists all available API resources (e.g., pods, services) but does not provide field-level documentation or definitions.kubectl get --helpshows help for thegetcommand, not resource-specific field definitions.kubectl showis not a valid kubectl command; the correct command for displaying resource details iskubectl describeorkubectl get, but neither provides field definitions likeexplaindoes.