kubectl explain to inspect Kubernetes resource types and their fields directly from the terminal. This is especially useful when you don’t know a resource’s full name, its short name, or the exact API version. kubectl explain reads the API schema (OpenAPI) exposed by your cluster, so the output reflects what your API server supports.

- Discover available resources with
kubectl api-resources. - Use the
NAMEorSHORTNAMESfrom that list when runningkubectl explain. - Inspect top-level fields (
spec,status,metadata) or drill into nested fields using dot notation. - Use
--recursiveto list all nested fields.
Using
kubectl explain
- Inspect top-level fields (types and short descriptions)
- Drill into a specific field with dot notation
- Show all nested fields with
--recursive
Tip:
kubectl explain reads the OpenAPI schema served by the API server, so it reflects the API groups and fields supported by your cluster. If a field is missing or differs from online docs, check the API group and version returned by kubectl api-resources and confirm your cluster version.Warning:
kubectl explain shows what the API server exposes. If your user account lacks permissions to read certain API groups, or if a CRD does not publish OpenAPI schema, those resources or fields may not appear in kubectl explain.- Official kubectl documentation: https://kubernetes.io/docs/reference/kubectl/
- Kubernetes API conventions: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md
- Kubernetes API resources overview: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/ (adjust version as needed)