Inject node labels into Kubernetes pod

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.

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 Tobias’s solution. The sidecar would be an additional container in the pod, which connects to the kubernetes API, queries the information you’re looking for (node labels), and writes the output to a shared volume. This could be implemented as an init container, or a sidecar that continuously syncs with the API.

Leave a Comment