website/docs/user-guide/downward-api
Ahmet Alp Balkan 0667180dd4 Remove self-links with domain names in docs (#4299)
* Remove self-links with domain names in docs

Fixes #4191. Skipping the tutorials we import from kubernetes/examples.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>

* update federation/index.md user-guide links

* update assign-pod-node.md links

* update dns-pod-service.md link

* update link in jobs-run-to-completion.md

* update link in minikube.md

* update PS link in minikube.md

* update links in stackpoint.md

* update links in storage.md

* fix link in vsphere.md

* fix links in deprecation-policy.md

* Update pick-right-solution.md

* Update web-ui-dashboard.md

* Update ingress.md

* Update federation-service-discovery.md

* Update user-guide.md

* Update expose-external-ip-address.md

* Update README.md

* Update README.md
2017-07-10 15:13:19 -07:00
..
volume Deprecation complete: container-environment ... (#3536) 2017-04-25 18:03:58 -07:00
OWNERS Adding OWNERS for docs. 2016-08-02 18:13:52 -07:00
README.md Remove self-links with domain names in docs (#4299) 2017-07-10 15:13:19 -07:00
dapi-container-resources.yaml Document examples of downward API exposing container resources via 2016-06-24 10:54:40 -04:00
dapi-pod.yaml Updating downward-api/index.md for spec.nodeName 2017-01-12 21:02:12 -05:00

README.md

Following these examples, you will create a pod with a container that consumes the pod's name, namespace, and resource values 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 pick the right solution 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 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 MY_POD_NAME=dapi-test-pod
2015-04-30T20:22:18.568087688Z MY_POD_NAMESPACE=default
2015-04-30T20:22:18.568092435Z MY_POD_IP=10.0.1.6

Example of environment variables with container resources

Use the dapi-container-resources.yaml file to create a Pod with a container that consumes the downward API exposing the container's resources.

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

Examine the logs

Grep through the pod logs to see that the pod was injected with the correct values:

$ kubectl logs dapi-test-pod | grep MY_
MY_MEM_LIMIT=67108864
MY_CPU_LIMIT=1
MY_MEM_REQUEST=33554432
MY_CPU_REQUEST=1