Rename labelNodeRoleExcludeBalancer to labelNodeExcludeBalancers (#97767)

* Rename labelNodeRoleExcludeBalancer to labelNodeExcludeBalancers

* Move labelNodeExcludeBalancers to well_known_labels

* Rename labelNodeExcludeBalancers to LabelNodeExcludeBalancers

* Fix LabelNodeExcludeBalancers reference

* Fix extra space on well_known_labels

* Rename commentary to match with the code name
This commit is contained in:
Edson (aka tuxpilgrim) 2021-02-17 23:16:51 -03:00 committed by GitHub
parent 3fb362bf0a
commit c417626c49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 10 deletions

View File

@ -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"
)

View File

@ -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
}

View File

@ -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: "",
},
},
},