Retrieve a particular host label from within a container

I’ve been deploying a multi deploying a multi-datacenter Cassandra cluster. Cassandra is “dc & rack -aware” and the name of the datacenter & rack can be specified in a properties file in a container.

Now, ideally, we would like to be able to add custom host labels on each host (eg: “dc=gce-eu-west”) and retrieve it from within the container. What’s the best approach to accomplish this?

You can add custom labels to hosts, services, and containers today, and schedule where containers run based on them.

An “introspection API” is coming in the next couple releases that will let you hit something like http://169.254.169.250/ to get info about the container, the service it’s a member of, the host, etc as a JSON document, or as EC2 metadata-style URLs. (@son @ibuildthecloud we should make sure labels are included.)

For today the closest thing is to set the scheduling to go to hosts with that label, then put a DC= environment variable on the container or service with the same value. So you’re duplicating the data which isn’t ideal, but it will work.