diff --git a/cmd/kubeadm/app/phases/markcontrolplane/markcontrolplane.go b/cmd/kubeadm/app/phases/markcontrolplane/markcontrolplane.go index c68f80f7fd6..dd4c89eca6d 100644 --- a/cmd/kubeadm/app/phases/markcontrolplane/markcontrolplane.go +++ b/cmd/kubeadm/app/phases/markcontrolplane/markcontrolplane.go @@ -19,31 +19,23 @@ package markcontrolplane import ( "fmt" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" clientset "k8s.io/client-go/kubernetes" "k8s.io/kubernetes/cmd/kubeadm/app/constants" "k8s.io/kubernetes/cmd/kubeadm/app/util/apiclient" ) +// labelsToAdd holds a list of labels that are applied on kubeadm managed control plane nodes var labelsToAdd = []string{ - // TODO: remove this label: - // https://github.com/kubernetes/kubeadm/issues/2200 - constants.LabelNodeRoleOldControlPlane, constants.LabelNodeRoleControlPlane, constants.LabelExcludeFromExternalLB, } // MarkControlPlane taints the control-plane and sets the control-plane label func MarkControlPlane(client clientset.Interface, controlPlaneName string, taints []v1.Taint) error { - // TODO: remove this "deprecated" amend and pass "labelsToAdd" directly: - // https://github.com/kubernetes/kubeadm/issues/2200 - labels := make([]string, len(labelsToAdd)) - copy(labels, labelsToAdd) - labels[0] = constants.LabelNodeRoleOldControlPlane + "(deprecated)" - fmt.Printf("[mark-control-plane] Marking the node %s as control-plane by adding the labels: %v\n", - controlPlaneName, labels) + controlPlaneName, labelsToAdd) if len(taints) > 0 { taintStrs := []string{} diff --git a/cmd/kubeadm/app/phases/markcontrolplane/markcontrolplane_test.go b/cmd/kubeadm/app/phases/markcontrolplane/markcontrolplane_test.go index cb9275124ab..b171072f80a 100644 --- a/cmd/kubeadm/app/phases/markcontrolplane/markcontrolplane_test.go +++ b/cmd/kubeadm/app/phases/markcontrolplane/markcontrolplane_test.go @@ -49,26 +49,25 @@ func TestMarkControlPlane(t *testing.T) { existingLabels: []string{""}, existingTaints: nil, newTaints: []v1.Taint{kubeadmconstants.OldControlPlaneTaint}, - expectedPatch: `{"metadata":{"labels":{"node-role.kubernetes.io/control-plane":"","node-role.kubernetes.io/master":"","node.kubernetes.io/exclude-from-external-load-balancers":""}},"spec":{"taints":[{"effect":"NoSchedule","key":"node-role.kubernetes.io/master"}]}}`, + expectedPatch: `{"metadata":{"labels":{"node-role.kubernetes.io/control-plane":"","node.kubernetes.io/exclude-from-external-load-balancers":""}},"spec":{"taints":[{"effect":"NoSchedule","key":"node-role.kubernetes.io/master"}]}}`, }, { name: "control-plane label and taint missing but taint not wanted", existingLabels: []string{""}, existingTaints: nil, newTaints: nil, - expectedPatch: `{"metadata":{"labels":{"node-role.kubernetes.io/control-plane":"","node-role.kubernetes.io/master":"","node.kubernetes.io/exclude-from-external-load-balancers":""}}}`, + expectedPatch: `{"metadata":{"labels":{"node-role.kubernetes.io/control-plane":"","node.kubernetes.io/exclude-from-external-load-balancers":""}}}`, }, { name: "control-plane label missing", existingLabels: []string{""}, existingTaints: []v1.Taint{kubeadmconstants.OldControlPlaneTaint}, newTaints: []v1.Taint{kubeadmconstants.OldControlPlaneTaint}, - expectedPatch: `{"metadata":{"labels":{"node-role.kubernetes.io/control-plane":"","node-role.kubernetes.io/master":"","node.kubernetes.io/exclude-from-external-load-balancers":""}}}`, + expectedPatch: `{"metadata":{"labels":{"node-role.kubernetes.io/control-plane":"","node.kubernetes.io/exclude-from-external-load-balancers":""}}}`, }, { name: "control-plane taint missing", existingLabels: []string{ - kubeadmconstants.LabelNodeRoleOldControlPlane, kubeadmconstants.LabelNodeRoleControlPlane, kubeadmconstants.LabelExcludeFromExternalLB, }, @@ -79,7 +78,6 @@ func TestMarkControlPlane(t *testing.T) { { name: "nothing missing", existingLabels: []string{ - kubeadmconstants.LabelNodeRoleOldControlPlane, kubeadmconstants.LabelNodeRoleControlPlane, kubeadmconstants.LabelExcludeFromExternalLB, }, @@ -90,7 +88,6 @@ func TestMarkControlPlane(t *testing.T) { { name: "has taint and no new taints wanted", existingLabels: []string{ - kubeadmconstants.LabelNodeRoleOldControlPlane, kubeadmconstants.LabelNodeRoleControlPlane, kubeadmconstants.LabelExcludeFromExternalLB, }, diff --git a/cmd/kubeadm/app/util/staticpod/utils.go b/cmd/kubeadm/app/util/staticpod/utils.go index 5d99d350e8c..e6920213e56 100644 --- a/cmd/kubeadm/app/util/staticpod/utils.go +++ b/cmd/kubeadm/app/util/staticpod/utils.go @@ -288,13 +288,6 @@ func createHTTPProbe(host, path string, port int, scheme v1.URIScheme, initialDe // GetAPIServerProbeAddress returns the probe address for the API server func GetAPIServerProbeAddress(endpoint *kubeadmapi.APIEndpoint) string { - // In the case of a self-hosted deployment, the initial host on which kubeadm --init is run, - // will generate a DaemonSet with a nodeSelector such that all nodes with the label - // node-role.kubernetes.io/master='' will have the API server deployed to it. Since the init - // is run only once on an initial host, the API advertise address will be invalid for any - // future hosts that do not have the same address. Furthermore, since liveness and readiness - // probes do not support the Downward API we cannot dynamically set the advertise address to - // the node's IP. The only option then is to use localhost. if endpoint != nil && endpoint.AdvertiseAddress != "" { return getProbeAddress(endpoint.AdvertiseAddress) }