Reputation: 1206
In kubernetes we can easily expose certain params and values through environment variables. Examples of these can be the node IP, the container uid, etc.
Example
- name: POD_ID
valueFrom:
fieldRef:
fieldPath: metadata.uid
However, I was wondering if there is a way to list the possible references that can be included in the pod. Either in the form of an API reference or dynamically on a pod.
Upvotes: 3
Views: 857
Reputation: 1699
This is called downwardAPI.
Also variables
or fields
can exposed using environment variable as you mentioned & also via volume file.
Full documentation is here: https://kubernetes.io/docs/concepts/workloads/pods/downward-api/#available-fields. Some excerpts are below.
Pod & container field reference are available via environment variable using fieldRef
& resourceFieldRef
.
status.hostIP
, metadata.labels
, metadata.annotations['<KEY>']
etc.resourceFieldRef
requests.memory
, limits.cpu
, requests.hugepages-*
etcUpvotes: 0
Reputation: 1206
Figured it out myself, you can only reference the variables that are also exposed if you kubectl edit pod <podname>
a pod.
Upvotes: 3