Container Runtimes

Docker

rkt

Reference

Referencing dynamic data

Overview

Sometimes it can be useful to refer to data in a Container Linux Config that isn't known until a machine boots, like its network address. This can be accomplished with coreos-metadata. coreos-metadata is a very basic utility that fetches information about the current machine and makes it available for consumption. By making it a dependency of services which requires this information, systemd will ensure that coreos-metadata has successfully completed before starting these services. These services can then simply source the fetched information and let systemd perform the environment variable expansions.

As of version 0.2.0, ct has support for making this easy for users. In specific sections of a config, users can enter in dynamic data between {}, and ct will handle enabling the coreos-metadata service and using the information it provides.

The available information varies by provider, and is expressed in different variables by coreos-metadata. If this feature is used a --provider flag must be passed to ct. Currently, the etcd and flannel sections are the only ones which support this feature.

Supported data by provider

This is the information available in each provider.

HOSTNAME

PRIVATE_IPV4

PUBLIC_IPV4

PRIVATE_IPV6

PUBLIC_IPV6

Azure

✓

✓

Digital Ocean

✓

✓

✓

✓

✓

EC2

✓

✓

✓

GCE

✓

✓

✓

Packet

✓

✓

✓

✓

OpenStack-Metadata

✓

✓

✓

Vagrant-Virtualbox

✓

✓

Behind the scenes

For a more in-depth walk through of how this feature works, let's look at the etcd example from the examples document.

This drop-in specifies that etcd should run after the coreos-metadata service, and it uses /run/metadata/coreos as an EnvironmentFile. This enables the coreos-metadata service, and puts the information it discovers into environment variables. These environment variables are then expanded by systemd when the service starts, inserting the dynamic data into the command-line flags to etcd.