Files
website/docs/user-guide/downward-api/dapi-pod.yaml
T
Brandon Cole 956dcf8cd6 Updating downward-api/index.md for spec.nodeName
There are a couple awesome enhancements that would benefit from being documented here:

1. `spec.nodeName` for obtaining the host name
2. `spec.serviceAccountName` for obtaining the name of the service account the pod is running under

Right now these enhancements are documented only in a couple of issues and pull requests:

1. https://github.com/kubernetes/kubernetes/pull/27880
2. https://github.com/kubernetes/kubernetes/issues/24657
3. https://github.com/kubernetes/kubernetes/issues/21317

I have verified the functionality in the latest codebase:

1. https://github.com/kubernetes/kubernetes/blob/master/pkg/api/v1/conversion.go#L200

Also updating downward-api/dapi-pod.yaml to add a concrete example.
2017-01-12 21:02:12 -05:00

32 lines
805 B
YAML

apiVersion: v1
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: MY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MY_POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: MY_POD_SERVICE_ACCOUNT
valueFrom:
fieldRef:
fieldPath: spec.serviceAccountName
restartPolicy: Never