inspection

kubectl explain

Prints documentation for a resource kind and its fields, sourced from the live cluster's OpenAPI schema. It is the offline-safe reference for authoring manifests against the exact API version your cluster serves.

kubectl explain RESOURCE[.FIELD.FIELD...] [--recursive] [flags]

Common flags

Flag Purpose
--recursive Show every nested field, not just the top level.
--api-version Explain a specific group/version (e.g. apps/v1).
--output plaintext (default) or plaintext-openapiv2 for legacy behavior.

Examples

kubectl explain pod.spec.containers

Documentation for the containers field of a Pod spec.

kubectl explain deployment --recursive | less

Full nested schema for a Deployment.

kubectl explain ingress --api-version=networking.k8s.io/v1

Explain a specific API group/version.

Gotcha

Fields are those the cluster actually serves - a CRD only appears if it is registered. In 1.28+ output uses OpenAPI v3 by default; add --output=plaintext-openapiv2 for the older format.

Related commands

← All kubectl commands · Docker vs Kubernetes