Skip to content

Commit

Permalink
kubeadm: work around hetzner private IP
Browse files Browse the repository at this point in the history
private IP is not yet accessible via Afterburn so let's advertise the
public IP on Hetzner

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
  • Loading branch information
tormath1 committed Jun 25, 2024
1 parent 6d377e6 commit e2c078b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
22 changes: 16 additions & 6 deletions kola/tests/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,7 @@ var (
"cgroupv1": false,
},
}
plog = capnslog.NewPackageLogger("github.com/flatcar/mantle", "kola/tests/kubeadm")
etcdConfig = conf.ContainerLinuxConfig(`
etcd:
advertise_client_urls: http://{PRIVATE_IPV4}:2379
listen_client_urls: http://0.0.0.0:2379`)
plog = capnslog.NewPackageLogger("github.com/flatcar/mantle", "kola/tests/kubeadm")
)

func init() {
Expand Down Expand Up @@ -307,6 +303,16 @@ func render(s string, p map[string]interface{}, b bool) (*bytes.Buffer, error) {
func setup(c cluster.TestCluster, params map[string]interface{}) (platform.Machine, error) {
plog.Infof("creating etcd node")

var ip string = "PRIVATE_IPV4"
if c.Platform() == "hetzner" {
ip = "PUBLIC_IPV4"
}

etcdConfig := conf.ContainerLinuxConfig(fmt.Sprintf(`
etcd:
advertise_client_urls: http://{%s}:2379
listen_client_urls: http://0.0.0.0:2379`, ip))

etcdNode, err := c.NewMachine(etcdConfig)
if err != nil {
return nil, fmt.Errorf("unable to create etcd node: %w", err)
Expand Down Expand Up @@ -342,7 +348,11 @@ func setup(c cluster.TestCluster, params map[string]interface{}) (platform.Machi
return nil, fmt.Errorf("unable to get etcd node health: %w", err)
}

params["Endpoints"] = []string{fmt.Sprintf("http://%s:2379", etcdNode.PrivateIP())}
if c.Platform() == "hetzner" {
params["Endpoints"] = []string{fmt.Sprintf("http://%s:2379", etcdNode.IP())}
} else {
params["Endpoints"] = []string{fmt.Sprintf("http://%s:2379", etcdNode.PrivateIP())}
}

plog.Infof("creating master node")

Expand Down
2 changes: 1 addition & 1 deletion kola/tests/kubeadm/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ cat << EOF > worker-config.yaml
EOF
systemctl start --quiet coreos-metadata
ipv4=$(cat /run/metadata/flatcar | grep -v -E '(IPV6|GATEWAY)' | grep IP | grep -E '({{ if eq .Platform "do" }}PUBLIC{{ else }}PRIVATE{{ end }}|LOCAL|DYNAMIC)' | cut -d = -f 2)
ipv4=$(cat /run/metadata/flatcar | grep -v -E '(IPV6|GATEWAY)' | grep IP | grep -E '({{ if or (eq .Platform "do") (eq .Platform "hetzner") }}PUBLIC{{ else }}PRIVATE{{ end }}|LOCAL|DYNAMIC)' | cut -d = -f 2)
kubeadm join --config worker-config.yaml --node-name "${ipv4}"
`
Expand Down

0 comments on commit e2c078b

Please sign in to comment.