Skip to content

Commit

Permalink
Remove exclude-from-external-load-balancers from single node clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
howardjohn committed Feb 5, 2024
1 parent 24e1bc3 commit 18bb5af
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/cluster/internal/create/actions/kubeadminit/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,17 @@ func (a *action) Execute(ctx *actions.ActionContext) error {
}
}

// Kubeadm will add `node.kubernetes.io/exclude-from-external-load-balancers` on control plane nodes.
// For single node clusters, this means we cannot have a load balancer at all (MetalLB, etc), so remove the label.
if len(allNodes) == 1 {
labelArgs := []string{"--kubeconfig=/etc/kubernetes/admin.conf", "label", "nodes", "--all", "node.kubernetes.io/exclude-from-external-load-balancers-"}
if err := node.Command(
"kubectl", labelArgs...,
).Run(); err != nil {
return errors.Wrap(err, "failed to remove control plane load balancer label")
}
}

// mark success
ctx.Status.End(true)
return nil
Expand Down

0 comments on commit 18bb5af

Please sign in to comment.