Downward API
Downward API exposes Pod and Container fields to running containers inside the pod. There are only two ways that we can do
- environment variables and
- files created by special volume type called downward API volume.
fieldRef
is used to reference pod fields and resourceFieldRef
is to reference containers fields in spec section.
The availability of information that we can reference for pod and containers through environment variables and volume can vary. For example, following pod fields information is common in case of both
metadata.name
metadata.namespace
metadata.uid
etc
Some only for environment variables are,
spec.nodeName
spec.serviceAccountName
status.hostIP
etc
Some only for volume are,
metadata.labels
metadata.annotations
etc
This list is present on official documentation given in the references section.
For container fields, only their resources field can be accessed.