<p>I am looking to deploy services to a Kubernetes cluster running over multiple zones and would like to be able to inject the region/zone labels into my pods using environment variables.</p>

<p>I have looked into the downward API however this only seems to allow you to inject labels/metadata from the pod/service and not from the node you are running the pod on.</p>

<p>If there is no way to inject the node labels another solution I thought about was having the container query the kubernetes/AWS API to fetch this information however that would mean adding quite a lot of complexity to my containers.</p>

<blockquote>
  <p>I thought about was having the container query the kubernetes/AWS API to fetch this information however that would mean adding quite a lot of complexity to my containers.</p>
</blockquote>

<p>This is currently the recommended approach for getting information not available in the downward API. To avoid the additional complexity in your containers, you could use a "sidecar" with a variation on <a href="https://stackoverflow.com/questions/36690446/inject-node-labels-into-kubernetes-pod/36699927#36699927">Tobias's solution</a>. The sidecar would be an additional container in the pod, which <a href="https://kubernetes.io/docs/user-guide/accessing-the-cluster/#accessing-the-api-from-a-pod" rel="noreferrer">connects to the kubernetes API</a>, queries the information you're looking for (node labels), and writes the output to a shared volume. This could be implemented as an <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" rel="noreferrer">init container</a>, or a sidecar that continuously syncs with the API.</p>
