-
Notifications
You must be signed in to change notification settings - Fork 39.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change EnvVarSource.FieldPath -> FieldRef and add example
- Loading branch information
Showing
18 changed files
with
88 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# 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](../../docs/getting-started-guides) 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/secrets/secret-pod.yaml` file to create a Pod with a container that consumes the | ||
downward API. | ||
|
||
```shell | ||
$ kubectl create -f examples/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: | ||
|
||
```shell | ||
$ kubectl log 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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: v1beta3 | ||
kind: Pod | ||
metadata: | ||
name: dapi-test-pod | ||
spec: | ||
containers: | ||
- name: test-container | ||
image: gcr.io/google_containers/busybox | ||
command: [ "/bin/sh", "-c", "env" ] | ||
env: | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: POD_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
restartPolicy: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters