-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Align node filtering with kubernetes service controller #370
Conversation
/assign @bowei |
/ok-to-test |
@lbernail Sorry for the long delay. This looks fine to me, once you have rebased. |
@rramkumar1 : no problem. I just did the rebase |
pkg/utils/utils.go
Outdated
@@ -54,6 +56,10 @@ const ( | |||
AddInstances | |||
// RemoveInstances used to record a call to RemoveInstances. | |||
RemoveInstances | |||
// Label for Master nodes | |||
LabelNodeRoleMaster = "node-role.kubernetes.io/master" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I didn't notice before: These constant are copied from the service controller code. Given that we don't vendor that code in here, how can we keep these values up-to-date?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to find a better solution but no obvious came to mind
The master label is unlikely to change because it's used in many tools (and the alpha annotation is just alpha and I don't think it's worth implementing feature gates for this use case)
Happy to revise this if you have a suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine as that is unlikely to change. Kubeadm also hardcoded it: https://github.com/kubernetes/kubernetes/blob/6ca14282562597709c909e9f7f3abdb600afc193/cmd/kubeadm/app/constants/constants.go#L181-L183
Could you update the comment to reference service controller?
// LabelNodeRoleMaster specifies that a node is a master
// This is a duplicate definition of the constant in:
// kuberentes/kubernetes/pkg/controller/service/service_controller.go
/lgtm |
pkg/utils/utils.go
Outdated
@@ -54,6 +56,10 @@ const ( | |||
AddInstances | |||
// RemoveInstances used to record a call to RemoveInstances. | |||
RemoveInstances | |||
// Label for Master nodes | |||
LabelNodeRoleMaster = "node-role.kubernetes.io/master" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine as that is unlikely to change. Kubeadm also hardcoded it: https://github.com/kubernetes/kubernetes/blob/6ca14282562597709c909e9f7f3abdb600afc193/cmd/kubeadm/app/constants/constants.go#L181-L183
Could you update the comment to reference service controller?
// LabelNodeRoleMaster specifies that a node is a master
// This is a duplicate definition of the constant in:
// kuberentes/kubernetes/pkg/controller/service/service_controller.go
pkg/utils/utils.go
Outdated
@@ -54,6 +56,10 @@ const ( | |||
AddInstances | |||
// RemoveInstances used to record a call to RemoveInstances. | |||
RemoveInstances | |||
// Label for Master nodes | |||
LabelNodeRoleMaster = "node-role.kubernetes.io/master" | |||
// Label for nodes excluded from load-balancing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the same comment and reference service controller?
// LabelNodeRoleExcludeBalancer specifies that the node should be
// exclude from load balancers created by a cloud provider.
// This is a duplicate definition of the constant in:
// kuberentes/kubernetes/pkg/controller/service/service_controller.go
@@ -339,7 +345,7 @@ IngressLoop: | |||
// TODO(rramkumar): Add a test for this. | |||
func GetReadyNodeNames(lister listers.NodeLister) ([]string, error) { | |||
var nodeNames []string | |||
nodes, err := lister.ListWithPredicate(NodeIsReady) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw the same logic is used in https://github.com/kubernetes/ingress-gce/blob/master/pkg/controller/translator/translator.go, is that relevant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should update that too yes
Not updating it did not break any of my tests but it makes a lot of sense to not include zones without nodes considered for load-balancing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes more sense, thanks for checking.
@@ -339,7 +345,7 @@ IngressLoop: | |||
// TODO(rramkumar): Add a test for this. | |||
func GetReadyNodeNames(lister listers.NodeLister) ([]string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we update the comment to reflect what it is doing now?
New changes are detected. LGTM label has been removed. |
I updated the comments and will add the same logic in translator.go |
@MrHohn I updated the PR to create a I'll do more testing on a cluster later this week |
pkg/utils/utils.go
Outdated
// This is a duplicate definition of the constant in: | ||
// kubernetes/kubernetes/pkg/controller/service/service_controller.go | ||
LabelNodeRoleMaster = "node-role.kubernetes.io/master" | ||
// LabelNodeRoleMaster specifies that a node is a master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should comment about LabelNodeRoleExcludeBalancer
here instead.
pkg/utils/utils.go
Outdated
@@ -335,19 +347,68 @@ IngressLoop: | |||
return | |||
} | |||
|
|||
// GetReadyNodeNames returns names of schedulable, ready nodes from the node lister. | |||
// GetReadyNodeNames returns names of ready nodes, excluding masters and ones exclued from load-balancing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we should still include the schedulable bit in comment, as a node can be both ready and non-schedulable.
pkg/utils/utils.go
Outdated
nodes, err := lister.ListWithPredicate(getNodeConditionPredicate()) | ||
if err != nil { | ||
return readyNodes, err | ||
} | ||
for _, n := range nodes { | ||
if n.Spec.Unschedulable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is duplicate with getNodeConditionPredicate()
, which already checks node.Spec.Unschedulable
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely, I missed that
I will export GetNodeConditionPredicate and simplify accordingly
Thanks, that makes sense to me, left some minor comments. |
@lbernail Thanks for the works, this LGTM. Could you squash the fix-up commits? |
Sure, I will take care of it in the next few days |
@MrHohn I squashed the PR into 2 commits, let me know if that works for you
|
@lbernail LGTM. Thanks for verifying the change. |
Addresses #292
Use the same node selection logic as the kubernetes service controller:
alpha.service-controller.kubernetes.io/exclude-balancer
In the kubernetes service controller, the service node exclusion is a feature gate but there is no feature gate on this controller, so I removed the feature gate test (it seems unlikely that this label would be applied to a node that doesn't require exclusion). If you think it's not a good call I can revisit this.
I have a custom build available on dockerhub for testing:
lbernail/glbc:v0.2