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
Get a shell into the Container that is running in your Pod:
175
+
Get a shell into the container that is running in your Pod:
180
176
181
177
```shell
182
178
kubectl exec -it kubernetes-downwardapi-volume-example-2 -- sh
@@ -187,46 +183,56 @@ In your shell, view the `cpu_limit` file:
187
183
```shell
188
184
/# cat /etc/podinfo/cpu_limit
189
185
```
186
+
190
187
You can use similar commands to view the `cpu_request`, `mem_limit` and
191
188
`mem_request` files.
192
189
193
-
194
-
195
190
<!-- discussion -->
196
191
192
+
<!-- TODO: This section should be extracted out of the task page. -->
197
193
## Capabilities of the Downward API
198
194
199
195
The following information is available to containers through environment
200
196
variables and `downwardAPI` volumes:
201
197
202
198
* Information available via `fieldRef`:
199
+
203
200
*`metadata.name` - the pod's name
204
201
*`metadata.namespace` - the pod's namespace
205
202
*`metadata.uid` - the pod's UID
206
-
*`metadata.labels['<KEY>']` - the value of the pod's label `<KEY>` (for example, `metadata.labels['mylabel']`)
207
-
*`metadata.annotations['<KEY>']` - the value of the pod's annotation `<KEY>` (for example, `metadata.annotations['myannotation']`)
203
+
*`metadata.labels['<KEY>']` - the value of the pod's label `<KEY>`
204
+
(for example, `metadata.labels['mylabel']`)
205
+
*`metadata.annotations['<KEY>']` - the value of the pod's annotation `<KEY>`
206
+
(for example, `metadata.annotations['myannotation']`)
207
+
208
208
* Information available via `resourceFieldRef`:
209
+
209
210
* A Container's CPU limit
210
211
* A Container's CPU request
211
212
* A Container's memory limit
212
213
* A Container's memory request
213
-
* A Container's hugepages limit (providing that the `DownwardAPIHugePages`[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled)
214
-
* A Container's hugepages request (providing that the `DownwardAPIHugePages`[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled)
214
+
* A Container's hugepages limit (provided that the `DownwardAPIHugePages`
215
+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled)
216
+
* A Container's hugepages request (provided that the `DownwardAPIHugePages`
217
+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled)
215
218
* A Container's ephemeral-storage limit
216
219
* A Container's ephemeral-storage request
217
220
218
221
In addition, the following information is available through
219
222
`downwardAPI` volume `fieldRef`:
220
223
221
-
*`metadata.labels` - all of the pod's labels, formatted as `label-key="escaped-label-value"` with one label per line
222
-
*`metadata.annotations` - all of the pod's annotations, formatted as `annotation-key="escaped-annotation-value"` with one annotation per line
224
+
*`metadata.labels` - all of the pod's labels, formatted as `label-key="escaped-label-value"`
225
+
with one label per line
226
+
*`metadata.annotations` - all of the pod's annotations, formatted as
227
+
`annotation-key="escaped-annotation-value"` with one annotation per line
223
228
224
229
The following information is available through environment variables:
225
230
226
231
*`status.podIP` - the pod's IP address
227
-
*`spec.serviceAccountName` - the pod's service account name, available since v1.4.0-alpha.3
228
-
*`spec.nodeName` - the node's name, available since v1.4.0-alpha.3
229
-
*`status.hostIP` - the node's IP, available since v1.7.0-alpha.1
232
+
*`spec.serviceAccountName` - the pod's service account name
233
+
*`spec.nodeName` - the name of the node to which the scheduler always attempts to
234
+
schedule the pod
235
+
*`status.hostIP` - the IP of the node to which the Pod is assigned
230
236
231
237
{{< note >}}
232
238
If CPU and memory limits are not specified for a Container, the
@@ -241,7 +247,7 @@ basis. For more information, see
241
247
242
248
## Motivation for the Downward API
243
249
244
-
It is sometimes useful for a Container to have information about itself, without
250
+
It is sometimes useful for a container to have information about itself, without
245
251
being overly coupled to Kubernetes. The Downward API allows containers to consume
246
252
information about themselves or the cluster without using the Kubernetes client
247
253
or API server.
@@ -252,19 +258,17 @@ application, but that is tedious and error prone, and it violates the goal of lo
252
258
coupling. A better option would be to use the Pod's name as an identifier, and
253
259
inject the Pod's name into the well-known environment variable.
0 commit comments