You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can pass information from available Container-level fields using
42
+
`resourceFieldRef`.
43
+
44
+
### Information available via `fieldRef` {#downwardapi-fieldRef}
45
+
46
+
For most Pod-level fields, you can provide them to a container either as
47
+
an environment variable or using a `downwardAPI` volume. The fields available
48
+
via either mechanism are:
49
+
50
+
`metadata.name`
51
+
: the pod's name
52
+
53
+
`metadata.namespace`
54
+
: the pod's {{< glossary_tooltip text="namespace" term_id="namespace" >}}
55
+
56
+
`metadata.uid`
57
+
: the pod's unique ID
58
+
59
+
`metadata.annotations['<KEY>']`
60
+
: the value of the pod's {{< glossary_tooltip text="annotation" term_id="annotation" >}} named `<KEY>` (for example, `metadata.annotations['myannotation']`)
61
+
62
+
`metadata.labels['<KEY>']`
63
+
: the text value of the pod's {{< glossary_tooltip text="label" term_id="label" >}} named `<KEY>` (for example, `metadata.labels['mylabel']`)
64
+
65
+
`spec.serviceAccountName`
66
+
: the name of the pod's {{< glossary_tooltip text="service account" term_id="service-account" >}}
67
+
68
+
`spec.nodeName`
69
+
: the name of the {{< glossary_tooltip term_id="node" text="node">}} where the Pod is executing
70
+
71
+
`status.hostIP`
72
+
: the primary IP address of the node to which the Pod is assigned
73
+
74
+
`status.podIP`
75
+
: the pod's primary IP address (usually, its IPv4 address)
76
+
77
+
In addition, the following information is available through
78
+
a `downwardAPI` volume `fieldRef`, but **not as environment variables**:
79
+
80
+
`metadata.labels`
81
+
: all of the pod's labels, formatted as `label-key="escaped-label-value"` with one label per line
82
+
83
+
`metadata.annotations`
84
+
: all of the pod's annotations, formatted as `annotation-key="escaped-annotation-value"` with one annotation per line
85
+
86
+
### Information available via `resourceFieldRef` {#downwardapi-resourceFieldRef}
87
+
88
+
These container-level fields allow you to provide information about
89
+
[requests and limits](/docs/concepts/configuration/manage-resources-containers/#requests-and-limits)
90
+
for resources such as CPU and memory.
91
+
92
+
93
+
`resource: limits.cpu`
94
+
: A container's CPU limit
95
+
96
+
`resource: requests.cpu`
97
+
: A container's CPU request
98
+
99
+
`resource: limits.memory`
100
+
: A container's memory limit
101
+
102
+
`resource: requests.memory`
103
+
: A container's memory request
104
+
105
+
`resource: limits.hugepages-*`
106
+
: A container's hugepages limit (provided that the `DownwardAPIHugePages`[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled)
107
+
108
+
`resource: requests.hugepages-*`
109
+
: A container's hugepages request (provided that the `DownwardAPIHugePages`[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled)
110
+
111
+
`resource: limits.ephemeral-storage`
112
+
: A container's ephemeral-storage limit
113
+
114
+
`resource: requests.ephemeral-storage`
115
+
: A container's ephemeral-storage request
116
+
117
+
#### Fallback information for resource limits
118
+
119
+
If CPU and memory limits are not specified for a container, and you use the
120
+
downward API to try to expose that information, then the
121
+
kubelet defaults to exposing the maximum allocatable value for CPU and memory
122
+
(based on the [node allocatable](/docs/tasks/administer-cluster/reserve-compute-resources/#node-allocatable)
123
+
calculation).
124
+
125
+
## {{% heading "whatsnext" %}}
126
+
127
+
You can read about [`downwardAPI` volumes](/docs/concepts/storage/volumes/#downwardapi).
128
+
129
+
You can try using the downward API to expose container- or Pod-level information:
130
+
* as [environment variables](/docs/tasks/inject-data-application/environment-variable-expose-pod-information/#the-downward-api)
131
+
* as [files in `downwardAPI` volume](/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/)
0 commit comments