On 04/20,
xie...@gmail.com wrote:
> Dear all,
>
> Recently I was trying to build an OEM version of CoreOS to work best for
> the cloud platform running by the company I work for. Basically we have in
> our ability to offer customer free MPLS VPN across regions simply by having
> an extra NIC, there is absolutely no setup/config needed from the user.
>
> Now current user of CoreOS has the ability to use $public_ipv4 and
> $private_ipv4 in their cloud-config.yaml and this will be replaced by
> coreos-cloudinit as the code shown here:
>
> // TODO(jonboulle): this is getting unwieldy, should be able to simplify
> the interface somehowfunc NewEnvironment(root, configRoot, workspace,
> sshKeyName string, metadata datasource.Metadata) *Environment {
> firstNonNull := func(ip net.IP, env string) string { if ip == nil
> { return env } return ip.String
> () } substitutions := map[string]string{ "
My suggestion moving foward is to have your OEM cloud-config write a
file containing any metadata you want to expose Then ask your users to
source that environment in their services (assuming they need it) and
use the variable directly. For example:
OEM cloud-config:
write_files:
- path: /run/my-cloud-provider/environment
content: MYCLOUDPROVIDER_IPV4_VPN=10.0.1.2
User cloud-config
coreos:
units:
- name: etcd.service
drop-ins:
- name: args.conf
contents: |
[Service]
EnvironmentFile=/etc/environment
EnvironmentFile=/run/my-cloud-provider/environment
ExecStart=/usr/bin/etcd \
-advertise-client-urls=http://${COREOS_PUBLIC_IPV4}:2379 \
-initial-advertise-peer-urls=http://${MYCLOUDPROVIDER_IPV4_VPN}:2380 \
-listen-client-urls=
http://0.0.0.0:2379 \
-listen-peer-urls=http://${MYCLOUDPROVIDER_IPV4_VPN}:2380
-Alex