Access labels during runtime in kubernetes

9/14/2015

Is there a way for my application to access the labels assigned to the pod / service during runtime?

Either via client API or via ENV / passed variables to the docker container?

-- ptomasroos
google-compute-engine
kubernetes

1 Answer

9/14/2015

The Downward API is designed to automatically expose information about the pod's configuration to the pod using environment variables. As of Kubernetes 1.0 is only exposes the pod's name and namespace. Adding labels to the Downward API is being discussed in #560 but isn't currently implemented.

In the mean time, your application can query the Kubernetes apiserver and introspect it's configuration to determine what labels have been set.

-- Robert Bailey
Source: StackOverflow