The Kubernetes downward API exposes Pod name, namespace, labels and limits to containers
Answer: Expose Pod fields to a container as environment variables (fieldRef, or resourceFieldRef for requests and limits) or as files in a downwardAPI volume. The downward API lets containers consume information about themselves or the cluster without using the Kubernetes client or API server.
Example
env:
- name: MY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: MY_CPU_LIMIT
valueFrom:
resourceFieldRef:
containerName: app
resource: limits.cpu
What is available where
- Env vars or volume:
metadata.name,metadata.namespace,metadata.uid, and a single annotation or label such asmetadata.labels['mylabel']. - Environment variables only: the name of the pod's service account, the name of the node, the node IP address and the pod's primary IP address (the
specandstatusfields). - Volume only:
metadata.labelsandmetadata.annotationsas a whole, one per line, as read-only plain text files. resourceFieldRefcovers container-level requests and limits for resources such as CPU and memory.
Behavior to know
- If a container's CPU and memory are resized while it runs, a downward API volume will be updated, but environment variables are not updated unless the container restarts.
- If CPU and memory limits are not specified, the kubelet exposes the maximum allocatable value for CPU and memory based on the node allocatable calculation.
Why
Some applications assume a particular well-known environment variable holds a unique identifier. Wrapping the application is tedious and error-prone and violates the goal of low coupling; the Pod's name can be used instead.
See also
Claims
- id: C1 claim: There are two ways to expose Pod fields: env vars and volume files. source: S1 evidence: "There are two ways to expose Pod and container fields to a running container"
- id: C2 claim: Env vars are not updated after a resize unless the container restarts. source: S1 evidence: "environment variables will not be updated unless the container restarts"
- id: C3 claim: MY_NODE_NAME comes from spec.nodeName. source: S2 evidence: "environment variable gets its value from the Pod's
spec.nodeNamefield"
Sources
- [S1] Downward API. Kubernetes docs. https://kubernetes.io/docs/concepts/workloads/pods/downward-api/ . License: CC-BY-4.0. Accessed 2026-11-18.
- [S2] Expose Pod Information to Containers Through Environment Variables (source page). kubernetes/website (GitHub). https://github.com/kubernetes/website/blob/main/content/en/docs/tasks/inject-data-application/environment-variable-expose-pod-information.md . License: CC-BY-4.0. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Kubernetes docs, Downward API; kubernetes/website (GitHub), Expose Pod Information to Containers Through Environment Variables (source page). CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Kubernetes docs, Downward API; kubernetes/website (GitHub), Expose Pod Information to Containers Through Environment Variables (source page). CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors.
Cite this
iinventedlight. 2026. "The Kubernetes downward API exposes Pod name, namespace, labels and limits to containers." iinventedlight Library, iil:note:wvs4h0tw, version of 2026-11-18. https://iinventedlight.com/library/notes/kubernetes-downward-api/. License: CC-BY-4.0.
@misc{iil_note_wvs4h0tw,
author = {{iinventedlight}},
title = {{The Kubernetes downward API exposes Pod name, namespace, labels and limits to containers}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/kubernetes-downward-api/},
note = {Permanent ID iil:note:wvs4h0tw. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/kubernetes-downward-api.md.