liveBook · Manning

Kubectl explain

As explained in Kubernetes in Action, Second Edition

kubectl explain is a Kubernetes command that displays documentation for the fields and structure of an API object type.

kubectl explain displays command-line documentation for a Kubernetes API object kind, including its description, API version, and available fields. Use it when creating manifests or checking an unfamiliar field instead of guessing its spelling or structure. section 4.2.2 section 4.4

Explore an object progressively:

  • Start with kubectl explain <kind> to see the object description and top-level fields, such as apiVersion, kind, metadata, spec, and status. section 4.2.2
  • Drill into nested fields with a path such as kubectl explain node.spec. section 4.2.2
  • Specify --api-version when versions expose different fields or default values, and use --recursive to print the complete field hierarchy without descriptions. section 4.2.2

Finding a field selector

Before filtering events with kubectl get ev --field-selector type=Warning, run kubectl explain events to confirm that the type field accepts Normal or Warning. For a pod manifest, use kubectl explain pods to inspect available fields while adding container settings. section 4.3.1 section 5.2.1

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains object descriptions, nested fields, API versions, and recursive structure, but does not replace complete API reference documentation.
Examples
Demonstrates Node fields, node.spec, Event type values, warning-event filtering, and pod manifest construction.
What it assumes
Assumes familiarity with kubectl commands and Kubernetes object kinds while introducing field paths through concrete Node, Event, and Pod examples.
What you can do after
Apply it via kubectl to inspect API schemas and choose valid fields while writing manifests or filtering events.
How it connects
Connects Kubernetes API objects with API versions, YAML manifests, Event objects, and field selectors.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.