From 2afdffb879348ce151c21de0ecfeeafdbbb647c2 Mon Sep 17 00:00:00 2001 From: wangyysde Date: Fri, 9 Apr 2021 14:17:19 +0800 Subject: [PATCH 1/2] the node.kubernetes.io/exclude-from-external-load-balancers label on upgrade --- cmd/kubeadm/app/cmd/upgrade/apply.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cmd/kubeadm/app/cmd/upgrade/apply.go b/cmd/kubeadm/app/cmd/upgrade/apply.go index d8bc71dfb63..01227beaef1 100644 --- a/cmd/kubeadm/app/cmd/upgrade/apply.go +++ b/cmd/kubeadm/app/cmd/upgrade/apply.go @@ -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 { From c02e4b522929e44fe59529575949c0161248b2c9 Mon Sep 17 00:00:00 2001 From: wangyysde Date: Sat, 10 Apr 2021 14:30:35 +0800 Subject: [PATCH 2/2] remove LabelControlPlaneNodesWithExcludeFromLB function as the statement call it has be removed --- cmd/kubeadm/app/phases/upgrade/postupgrade.go | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/cmd/kubeadm/app/phases/upgrade/postupgrade.go b/cmd/kubeadm/app/phases/upgrade/postupgrade.go index f52f625ad11..91abf0895a8 100644 --- a/cmd/kubeadm/app/phases/upgrade/postupgrade.go +++ b/cmd/kubeadm/app/phases/upgrade/postupgrade.go @@ -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 -}