diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go index fb7102f8..d4031cf4 100644 --- a/pkg/cluster/cluster.go +++ b/pkg/cluster/cluster.go @@ -116,7 +116,7 @@ func CreateCluster(ctx context.Context, cluster *k3d.Cluster, runtime k3drt.Runt */ // Worker defaults (per cluster) - // connection url + // connection url is always the name of the first master node (index 0) connectionURL := fmt.Sprintf("https://%s:%s", generateNodeName(cluster.Name, k3d.MasterRole, 0), k3d.DefaultAPIPort) nodeSetup := func(node *k3d.Node, suffix int) error { @@ -141,7 +141,7 @@ func CreateCluster(ctx context.Context, cluster *k3d.Cluster, runtime k3drt.Runt // the cluster has an init master node, but its not this one, so connect it to the init node if cluster.InitNode != nil && !node.MasterOpts.IsInit { - node.Args = append(node.Args, "--server", fmt.Sprintf("https://%s:%s", cluster.InitNode.Name, k3d.DefaultAPIPort)) + node.Env = append(node.Env, fmt.Sprintf("K3S_URL=%s", connectionURL)) } } else if node.Role == k3d.WorkerRole { diff --git a/pkg/cluster/node.go b/pkg/cluster/node.go index 9ce2443b..010396f8 100644 --- a/pkg/cluster/node.go +++ b/pkg/cluster/node.go @@ -170,7 +170,9 @@ func DeleteNode(runtime runtimes.Runtime, node *k3d.Node) error { // patchWorkerSpec adds worker node specific settings to a node func patchWorkerSpec(node *k3d.Node) error { - node.Args = append([]string{"agent"}, node.Args...) + if node.Cmd == nil { + node.Cmd = []string{"agent"} + } return nil } @@ -178,7 +180,9 @@ func patchWorkerSpec(node *k3d.Node) error { func patchMasterSpec(node *k3d.Node) error { // command / arguments - node.Args = append([]string{"server"}, node.Args...) + if node.Cmd == nil { + node.Cmd = []string{"server"} + } // Add labels and TLS SAN for the exposed API // FIXME: For now, the labels concerning the API on the master nodes are only being used for configuring the kubeconfig