Downward API

Downward API exposes Pod and Container fields to running containers inside the pod. There are only two ways that we can do

  1. environment variables and
  2. 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

  1. metadata.name
  2. metadata.namespace
  3. metadata.uid etc

Some only for environment variables are,

  1. spec.nodeName
  2. spec.serviceAccountName
  3. status.hostIP etc

Some only for volume are,

  1. metadata.labels
  2. 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.

References

  1. https://kubernetes.io/docs/concepts/workloads/pods/downward-api/