Remove exclude-from-external-load-balancers from single node clusters

Part of https://github.com/kubernetes-sigs/kind/issues/3506
This commit is contained in:
John Howard
2024-02-05 14:58:13 -08:00
parent 24e1bc3f2b
commit 18bb5af02f

View File

@@ -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