k3s/docs/user-guide/downward-api
Alex Robinson 68d6e3a8ae Replace ``` with ` when emphasizing something inline in docs/ 2015-07-19 09:05:17 +00:00
..
README.md Replace ``` with ` when emphasizing something inline in docs/ 2015-07-19 09:05:17 +00:00
dapi-pod.yaml move user docs to their new home 2015-07-14 10:26:36 -07:00

README.md

WARNING WARNING WARNING WARNING WARNING

PLEASE NOTE: This document applies to the HEAD of the source tree

If you are using a released version of Kubernetes, you should refer to the docs that go with that version.

The latest 1.0.x release of this document can be found [here](http://releases.k8s.io/release-1.0/docs/user-guide/downward-api/README.md).

Documentation for other releases can be found at releases.k8s.io.

Downward API example

Following this example, you will create a pod with a containers that consumes the pod's name and namespace using the downward API.

Step Zero: Prerequisites

This example assumes you have a Kubernetes cluster installed and running, and that you have installed the kubectl command line tool somewhere in your path. Please see the getting started for installation instructions for your platform.

Step One: Create the pod

Containers consume the downward API using environment variables. The downward API allows containers to be injected with the name and namespace of the pod the container is in.

Use the examples/downward-api/dapi-pod.yaml file to create a Pod with a container that consumes the downward API.

$ kubectl create -f docs/user-guide/downward-api/dapi-pod.yaml

Examine the logs

This pod runs the env command in a container that consumes the downward API. You can grep through the pod logs to see that the pod was injected with the correct values:

$ kubectl logs dapi-test-pod | grep POD_
2015-04-30T20:22:18.568024817Z POD_NAME=dapi-test-pod
2015-04-30T20:22:18.568087688Z POD_NAMESPACE=default

Analytics