Glenn Vandamme
Glenn Vandamme

Reputation: 1206

Way to get list of field references in Kubernetes

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

Answers (2)

Sumit Murari
Sumit Murari

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.

resourceFieldRef

Upvotes: 0

Glenn Vandamme
Glenn Vandamme

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

Related Questions