Merge pull request #100942 from wangyysde/remove-exclude-from-external-load-balancers

kubeadm:the node.kubernetes.io/exclude-from-external-load-balancers label removed on upgrade
This commit is contained in:
Kubernetes Prow Robot 2021-04-11 14:37:59 -07:00 committed by GitHub
commit cf2c817c5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 35 deletions

View File

@ -171,13 +171,6 @@ func runApply(flags *applyFlags, args []string) error {
return err
}
// TODO: https://github.com/kubernetes/kubeadm/issues/2375
fmt.Printf("[upgrade/postupgrade] Applying label %s='' to control plane Nodes\n",
kubeadmconstants.LabelExcludeFromExternalLB)
if err := upgrade.LabelControlPlaneNodesWithExcludeFromLB(client); err != nil {
return err
}
// Upgrade RBAC rules and addons.
klog.V(1).Infoln("[upgrade/postupgrade] upgrading RBAC rules and addons")
if err := upgrade.PerformPostUpgradeTasks(client, cfg, flags.dryRun); err != nil {

View File

@ -230,31 +230,3 @@ func LabelOldControlPlaneNodes(client clientset.Interface) error {
}
return nil
}
// LabelControlPlaneNodesWithExcludeFromLB finds all control plane nodes and applies the LabelExcludeFromExternalLB
// label to them.
// TODO: https://github.com/kubernetes/kubeadm/issues/2375
func LabelControlPlaneNodesWithExcludeFromLB(client clientset.Interface) error {
selectorControlPlane := labels.SelectorFromSet(labels.Set(map[string]string{
kubeadmconstants.LabelNodeRoleControlPlane: "",
}))
nodesWithLabel, err := client.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{
LabelSelector: selectorControlPlane.String(),
})
if err != nil {
return errors.Wrapf(err, "could not list nodes labeled with %q", kubeadmconstants.LabelNodeRoleControlPlane)
}
for _, n := range nodesWithLabel.Items {
if _, hasLabel := n.ObjectMeta.Labels[kubeadmconstants.LabelExcludeFromExternalLB]; hasLabel {
continue
}
err = apiclient.PatchNode(client, n.Name, func(n *v1.Node) {
n.ObjectMeta.Labels[kubeadmconstants.LabelExcludeFromExternalLB] = ""
})
if err != nil {
return err
}
}
return nil
}