Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

platform: allow CLC templating for dynamic IP address insertion #168

Merged
merged 4 commits into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions kola/tests/etcd/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func init() {
initial_advertise_peer_urls: http://{PRIVATE_IPV4}:2380
discovery: $discovery`),
Distros: []string{"cl"},
ExcludePlatforms: []string{"qemu", "qemu-unpriv"},
ExcludePlatforms: []string{"qemu-unpriv"},
})

register.Register(&register.Test{
Expand All @@ -54,7 +54,7 @@ etcd:
initial_advertise_peer_urls: http://{PRIVATE_IPV4}:2380
discovery: $discovery
`),
ExcludePlatforms: []string{"esx", "qemu", "qemu-unpriv"}, // etcd-member requires ct rendering
ExcludePlatforms: []string{"esx", "qemu-unpriv"}, // etcd-member requires ct rendering and networking
Distros: []string{"cl"},
})

Expand All @@ -73,7 +73,7 @@ etcd:
initial_advertise_peer_urls: http://127.0.0.1:2380
`),
Distros: []string{"cl"},
ExcludePlatforms: []string{"qemu", "qemu-unpriv"},
ExcludePlatforms: []string{"qemu-unpriv"},
})
}

Expand Down
4 changes: 2 additions & 2 deletions kola/tests/flannel/flannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func init() {
ClusterSize: 3,
Name: "cl.flannel.udp",
Distros: []string{"cl"},
ExcludePlatforms: []string{"qemu", "qemu-unpriv"},
ExcludePlatforms: []string{"qemu-unpriv"},
UserData: flannelConf.Subst("$type", "udp"),
})

Expand All @@ -72,7 +72,7 @@ func init() {
ClusterSize: 3,
Name: "cl.flannel.vxlan",
Distros: []string{"cl"},
ExcludePlatforms: []string{"qemu", "qemu-unpriv"},
ExcludePlatforms: []string{"qemu-unpriv"},
UserData: flannelConf.Subst("$type", "vxlan"),
})
}
Expand Down
2 changes: 1 addition & 1 deletion kola/tests/ignition/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func init() {
// ESX: Currently Ignition does not support static IPs during the initramfs
// DO: https://github.com/coreos/bugs/issues/2205
// Packet & QEMU: https://github.com/coreos/ignition/issues/645
ExcludePlatforms: []string{"esx", "do", "packet", "qemu"},
ExcludePlatforms: []string{"esx", "do", "packet"},
Distros: []string{"cl", "fcos", "rhcos"},
})
}
Expand Down
2 changes: 1 addition & 1 deletion kola/tests/locksmith/locksmith.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ etcd:
listen_peer_urls: http://{PRIVATE_IPV4}:2380
discovery: $discovery`),
Distros: []string{"cl"},
ExcludePlatforms: []string{"qemu", "qemu-unpriv"},
ExcludePlatforms: []string{"qemu-unpriv"},
})
register.Register(&register.Test{
Name: "coreos.locksmith.reboot",
Expand Down
5 changes: 5 additions & 0 deletions platform/local/dnsmasq.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ leasefile-ro
log-facility=-
pid-file=

# hardcode DNS servers to avoid using systemd-resolved on the unreachable 127.0.0.53
dhcp-option=6,1.1.1.1,1.0.0.1,8.8.8.8
no-resolv
no-hosts

enable-ra

# point NTP at this host (0.0.0.0 and :: are special)
Expand Down
2 changes: 1 addition & 1 deletion platform/local/flight.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewLocalFlight(opts *platform.Options, platformName platform.Name) (*LocalF
}

nsdialer := network.NewNsDialer(nshandle)
bf, err := platform.NewBaseFlightWithDialer(opts, platformName, "", nsdialer)
bf, err := platform.NewBaseFlightWithDialer(opts, platformName, "custom", nsdialer)
if err != nil {
nshandle.Close()
return nil, fmt.Errorf("creating new base flight failed: %v", err)
Expand Down
6 changes: 4 additions & 2 deletions platform/machine/esx/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ Wants=network-online.target

[Service]
Type=oneshot
Environment=OUTPUT=/run/metadata/coreos
Environment=OUTPUT=/run/metadata/flatcar
ExecStart=/usr/bin/mkdir --parent /run/metadata
ExecStart=/usr/bin/bash -c 'echo "COREOS_CUSTOM_PRIVATE_IPV4=$(ip addr show ens192 | grep "inet 10." | grep -Po "inet \K[\d.]+")\nCOREOS_CUSTOM_PUBLIC_IPV4=$(ip addr show ens192 | grep -v "inet 10." | grep -Po "inet \K[\d.]+")" > ${OUTPUT}'`, false)
ExecStart=/usr/bin/bash -c 'echo "COREOS_CUSTOM_PRIVATE_IPV4=$(ip addr show ens192 | grep "inet 10." | grep -Po "inet \K[\d.]+")\nCOREOS_CUSTOM_PUBLIC_IPV4=$(ip addr show ens192 | grep -v "inet 10." | grep -Po "inet \K[\d.]+")" > ${OUTPUT}'
ExecStartPost=/usr/bin/ln -fs /run/metadata/flatcar /run/metadata/coreos
`, false)

instance, err := ec.flight.api.CreateDevice(ec.vmname(), conf, ipPairMaybe)
if err != nil {
Expand Down
18 changes: 16 additions & 2 deletions platform/machine/qemu/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,29 @@ func (qc *Cluster) NewMachineWithOptions(userdata *conf.UserData, options platfo
ip := strings.Split(netif.DHCPv4[0].String(), "/")[0]

conf, err := qc.RenderUserData(userdata, map[string]string{
"$public_ipv4": ip,
"$private_ipv4": ip,
"$public_ipv4": "${COREOS_CUSTOM_PUBLIC_IPV4}",
"$private_ipv4": "${COREOS_CUSTOM_PRIVATE_IPV4}",
})
if err != nil {
qc.mu.Unlock()
return nil, err
}
qc.mu.Unlock()

conf.AddSystemdUnit("coreos-metadata.service", `[Unit]
Description=QEMU metadata agent
After=nss-lookup.target
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
Environment=OUTPUT=/run/metadata/flatcar
ExecStart=/usr/bin/mkdir --parent /run/metadata
ExecStart=/usr/bin/bash -c 'echo "COREOS_CUSTOM_PRIVATE_IPV4=`+ip+`\nCOREOS_CUSTOM_PUBLIC_IPV4=`+ip+`\n" > ${OUTPUT}'
ExecStartPost=/usr/bin/ln -fs /run/metadata/flatcar /run/metadata/coreos
`, false)

var confPath string
if conf.IsIgnition() {
confPath = filepath.Join(dir, "ignition.json")
Expand Down