You will never remember every field. You do not need to. The documentation is in the API server, and kubectl explain reads it.
Walk a path
Give it a kind, then a dotted path into the object:
text
learner@shallows:~$ kubectl explain pod.spec.restartPolicy
KIND: Pod
VERSION: v1
FIELD: restartPolicy <string>
DESCRIPTION:
Restart policy for all containers within the pod. One of Always, OnFailure,
Never. Default to Always.podkind.specsection.restartPolicyfield
kubectl explain pod alone prints the top level: apiVersion, kind, metadata, spec, status. Add a part to the path to go one level down.
Read the type
Each field has a type in angle brackets:
| Type | Means | In YAML |
|---|---|---|
<string> | Text | image: nginx |
<integer> | A number | containerPort: 80 |
<map[string]string> | Keys and values | labels: with lines under it |
<[]Container> | A list of Container objects | Each item starts with - |
A field marked -required- must be present, or apply refuses the object.
The whole map
--recursive prints every field under a path, nested, without the descriptions:
text
learner@shallows:~$ kubectl explain pod.spec --recursive
FIELDS:
containers <[]Container> -required-
name <string> -required-
image <string> -required-
ports <[]ContainerPort>
containerPort <integer> -required-
restartPolicy <string>That is the skeleton of every Pod manifest. The next lesson writes one.