I have a service running as a DaemonSet
across a number of kubernetes nodes. I would like to make some policy decisions based on the labels of the node on which each DaemonSet
pod is running. From within a container, how do I know on which node this pod is running? Given this information, looking up the node labels through the API should be relatively easy.
What I'm doing right now is passing in the node name as an environment variable, like this:
env:
- name: NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
Is that the correct way of getting at this information? More specifically, is there any sort of API call that will answer the question, "where am I?"?