diff --git a/staging/src/k8s.io/api/core/v1/well_known_labels.go b/staging/src/k8s.io/api/core/v1/well_known_labels.go index 1b6529bc249..c623340d938 100644 --- a/staging/src/k8s.io/api/core/v1/well_known_labels.go +++ b/staging/src/k8s.io/api/core/v1/well_known_labels.go @@ -58,4 +58,11 @@ const ( // controllers and kube-proxy to check if the Endpoint objects should be replicated when // using Headless Services IsHeadlessService = "service.kubernetes.io/headless" + + // LabelNodeExcludeBalancers specifies that the node should not be considered as a target + // for external load-balancers which use nodes as a second hop (e.g. many cloud LBs which only + // understand nodes). For services that use externalTrafficPolicy=Local, this may mean that + // any backends on excluded nodes are not reachable by those external load-balancers. + // Implementations of this exclusion may vary based on provider. + LabelNodeExcludeBalancers = "node.kubernetes.io/exclude-from-external-load-balancers" ) diff --git a/staging/src/k8s.io/cloud-provider/controllers/service/controller.go b/staging/src/k8s.io/cloud-provider/controllers/service/controller.go index f49a5c23b90..8ecbaf7bc80 100644 --- a/staging/src/k8s.io/cloud-provider/controllers/service/controller.go +++ b/staging/src/k8s.io/cloud-provider/controllers/service/controller.go @@ -55,13 +55,6 @@ const ( // should be changed appropriately. minRetryDelay = 5 * time.Second maxRetryDelay = 300 * time.Second - - // labelNodeRoleExcludeBalancer specifies that the node should not be considered as a target - // for external load-balancers which use nodes as a second hop (e.g. many cloud LBs which only - // understand nodes). For services that use externalTrafficPolicy=Local, this may mean that - // any backends on excluded nodes are not reachable by those external load-balancers. - // Implementations of this exclusion may vary based on provider. - labelNodeRoleExcludeBalancer = "node.kubernetes.io/exclude-from-external-load-balancers" ) type cachedService struct { @@ -615,7 +608,7 @@ func nodeSlicesEqualForLB(x, y []*v1.Node) bool { func (s *Controller) getNodeConditionPredicate() NodeConditionPredicate { return func(node *v1.Node) bool { - if _, hasExcludeBalancerLabel := node.Labels[labelNodeRoleExcludeBalancer]; hasExcludeBalancerLabel { + if _, hasExcludeBalancerLabel := node.Labels[v1.LabelNodeExcludeBalancers]; hasExcludeBalancerLabel { return false } diff --git a/staging/src/k8s.io/cloud-provider/controllers/service/controller_test.go b/staging/src/k8s.io/cloud-provider/controllers/service/controller_test.go index 1b308000a81..df2b1e09076 100644 --- a/staging/src/k8s.io/cloud-provider/controllers/service/controller_test.go +++ b/staging/src/k8s.io/cloud-provider/controllers/service/controller_test.go @@ -1382,7 +1382,7 @@ func Test_getNodeConditionPredicate(t *testing.T) { {want: true, input: &v1.Node{Spec: v1.NodeSpec{Unschedulable: true}, Status: v1.NodeStatus{Conditions: []v1.NodeCondition{{Type: v1.NodeReady, Status: v1.ConditionTrue}}}}}, {want: true, input: &v1.Node{Status: validNodeStatus, ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{}}}}, - {want: false, input: &v1.Node{Status: validNodeStatus, ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{labelNodeRoleExcludeBalancer: ""}}}}, + {want: false, input: &v1.Node{Status: validNodeStatus, ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{v1.LabelNodeExcludeBalancers: ""}}}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -1498,7 +1498,7 @@ func Test_shouldSyncNode(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "node", Labels: map[string]string{ - labelNodeRoleExcludeBalancer: "", + v1.LabelNodeExcludeBalancers: "", }, }, },