|
|
@ -510,11 +510,13 @@ ClusterCreatOpts: |
|
|
|
if !clusterCreateOpts.DisableLoadBalancer { |
|
|
|
if !clusterCreateOpts.DisableLoadBalancer { |
|
|
|
if cluster.ServerLoadBalancer == nil { |
|
|
|
if cluster.ServerLoadBalancer == nil { |
|
|
|
l.Log().Infof("No loadbalancer specified, creating a default one...") |
|
|
|
l.Log().Infof("No loadbalancer specified, creating a default one...") |
|
|
|
lbNode, err := LoadbalancerPrepare(ctx, runtime, cluster, &k3d.LoadbalancerCreateOpts{Labels: clusterCreateOpts.GlobalLabels}) |
|
|
|
cluster.ServerLoadBalancer = k3d.NewLoadbalancer() |
|
|
|
|
|
|
|
var err error |
|
|
|
|
|
|
|
cluster.ServerLoadBalancer.Node, err = LoadbalancerPrepare(ctx, runtime, cluster, &k3d.LoadbalancerCreateOpts{Labels: clusterCreateOpts.GlobalLabels}) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return fmt.Errorf("failed to prepare loadbalancer: %w", err) |
|
|
|
return fmt.Errorf("failed to prepare loadbalancer: %w", err) |
|
|
|
} |
|
|
|
} |
|
|
|
cluster.Nodes = append(cluster.Nodes, lbNode) // append lbNode to list of cluster nodes, so it will be considered during rollback
|
|
|
|
cluster.Nodes = append(cluster.Nodes, cluster.ServerLoadBalancer.Node) // append lbNode to list of cluster nodes, so it will be considered during rollback
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if len(cluster.ServerLoadBalancer.Config.Ports) == 0 { |
|
|
|
if len(cluster.ServerLoadBalancer.Config.Ports) == 0 { |
|
|
@ -525,8 +527,6 @@ ClusterCreatOpts: |
|
|
|
cluster.ServerLoadBalancer.Config = &lbConfig |
|
|
|
cluster.ServerLoadBalancer.Config = &lbConfig |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
cluster.ServerLoadBalancer.Node.RuntimeLabels = clusterCreateOpts.GlobalLabels |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// prepare to write config to lb container
|
|
|
|
// prepare to write config to lb container
|
|
|
|
configyaml, err := yaml.Marshal(cluster.ServerLoadBalancer.Config) |
|
|
|
configyaml, err := yaml.Marshal(cluster.ServerLoadBalancer.Config) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
@ -545,6 +545,7 @@ ClusterCreatOpts: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
cluster.ServerLoadBalancer.Node.HookActions = append(cluster.ServerLoadBalancer.Node.HookActions, writeLbConfigAction) |
|
|
|
cluster.ServerLoadBalancer.Node.HookActions = append(cluster.ServerLoadBalancer.Node.HookActions, writeLbConfigAction) |
|
|
|
|
|
|
|
cluster.ServerLoadBalancer.Node.Restart = true |
|
|
|
|
|
|
|
|
|
|
|
l.Log().Infof("Creating LoadBalancer '%s'", cluster.ServerLoadBalancer.Node.Name) |
|
|
|
l.Log().Infof("Creating LoadBalancer '%s'", cluster.ServerLoadBalancer.Node.Name) |
|
|
|
if err := NodeCreate(ctx, runtime, cluster.ServerLoadBalancer.Node, k3d.NodeCreateOpts{}); err != nil { |
|
|
|
if err := NodeCreate(ctx, runtime, cluster.ServerLoadBalancer.Node, k3d.NodeCreateOpts{}); err != nil { |
|
|
|