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
kubectl get
Lists one or more resources of a given type from the cluster. It is the primary read command for pods, services, deployments, and any other Kubernetes object, with flexible output formats for scripting and inspection.
kubectl describe
Shows a human-readable, aggregated view of a resource including its spec, status, related events, and controllers. It is the go-to command for debugging why a pod is Pending, CrashLoopBackOff, or otherwise misbehaving.
kubectl config
Reads and modifies kubeconfig files that define clusters, users, and contexts. It is how you switch between clusters, change the active namespace, and register new credentials.
kubectl cluster-info
Prints the endpoints of the control-plane services for the current context. The dump subcommand collects a large diagnostic bundle of cluster state for offline analysis.
kubectl top
Displays CPU and memory usage for nodes or pods, powered by the metrics.k8s.io API. Requires the metrics-server (or an equivalent aggregator) to be installed in the cluster.