From 82d600bb5c34b2c7352643d4d811941e063a8215 Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Thu, 20 Apr 2017 21:47:25 -0400 Subject: [PATCH] Exclude master from LoadBalancer / NodePort The servicecontroller documents that the master is excluded from the LoadBalancer / NodePort, but this is broken for clusters where we are using taints for the master (as introduced in 1.6), instead of marking the master as unschedulable. This restores the desired documented behaviour, by excluding nodes that are labeled as masters with the new 1.6 labels, even if they use the new 1.6 taints. Fix #33884 --- pkg/controller/service/BUILD | 1 + pkg/controller/service/servicecontroller.go | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/controller/service/BUILD b/pkg/controller/service/BUILD index 226f348bc72..f7004cb9cfe 100644 --- a/pkg/controller/service/BUILD +++ b/pkg/controller/service/BUILD @@ -16,6 +16,7 @@ go_library( ], tags = ["automanaged"], deps = [ + "//cmd/kubeadm/app/constants:go_default_library", "//pkg/api:go_default_library", "//pkg/api/v1:go_default_library", "//pkg/api/v1/helper:go_default_library", diff --git a/pkg/controller/service/servicecontroller.go b/pkg/controller/service/servicecontroller.go index a02e5fd5c2d..494b762ebba 100644 --- a/pkg/controller/service/servicecontroller.go +++ b/pkg/controller/service/servicecontroller.go @@ -34,6 +34,7 @@ import ( "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/record" "k8s.io/client-go/util/workqueue" + "k8s.io/kubernetes/cmd/kubeadm/app/constants" "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1" v1helper "k8s.io/kubernetes/pkg/api/v1/helper" @@ -599,10 +600,16 @@ func getNodeConditionPredicate() corelisters.NodeConditionPredicate { return func(node *v1.Node) bool { // We add the master to the node list, but its unschedulable. So we use this to filter // the master. - // TODO: Use a node annotation to indicate the master if node.Spec.Unschedulable { return false } + + // As of 1.6, we will taint the master, but not necessarily mark it unschedulable. + // Recognize nodes labeled as master, and filter them also, as we were doing previously. + if _, hasMasterRoleLabel := node.Labels[constants.LabelNodeRoleMaster]; hasMasterRoleLabel { + return false + } + // If we have no info, don't accept if len(node.Status.Conditions) == 0 { return false