Skip to content
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

Merged
merged 2 commits into from
Aug 7, 2018
Merged

Align node filtering with kubernetes service controller #370

merged 2 commits into from
Aug 7, 2018

Conversation

lbernail
Copy link
Contributor

@lbernail lbernail commented Jun 27, 2018

Addresses #292

Use the same node selection logic as the kubernetes service controller:

  • filter out master nodes
  • filter out non-ready node
  • filter out nodes with label 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

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 27, 2018
@rramkumar1
Copy link
Contributor

/assign @bowei

@rramkumar1
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 27, 2018
@rramkumar1
Copy link
Contributor

@lbernail Sorry for the long delay. This looks fine to me, once you have rebased.

@lbernail
Copy link
Contributor Author

@rramkumar1 : no problem. I just did the rebase

@@ -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"
Copy link
Contributor

@rramkumar1 rramkumar1 Jul 26, 2018

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?

Ref: https://github.com/kubernetes/kubernetes/blob/c97b2e0d1e663c94710664f73bf9faa878f014a5/pkg/controller/service/service_controller.go

Copy link
Contributor Author

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

Copy link
Member

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

@rramkumar1
Copy link
Contributor

/lgtm
/assign @MrHohn
Do you have any thoughts?

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 27, 2018
@@ -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"
Copy link
Member

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

@@ -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
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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

Copy link
Member

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) {
Copy link
Member

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?

@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 28, 2018
@lbernail
Copy link
Contributor Author

I updated the comments and will add the same logic in translator.go

@lbernail
Copy link
Contributor Author

@MrHohn I updated the PR to create a GetReadyNodes function which returns Nodes and not strings so it can be used in translator.go. I kept the GetReadyNodeNames function to avoid refactoring too many things but it now calls the GetReadyNodes function.
What do you think?

I'll do more testing on a cluster later this week

// 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
Copy link
Member

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.

@@ -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
Copy link
Member

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.

nodes, err := lister.ListWithPredicate(getNodeConditionPredicate())
if err != nil {
return readyNodes, err
}
for _, n := range nodes {
if n.Spec.Unschedulable {
Copy link
Member

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?

Copy link
Contributor Author

@lbernail lbernail Aug 1, 2018

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

@MrHohn
Copy link
Member

MrHohn commented Aug 1, 2018

I updated the PR to create a GetReadyNodes function which returns Nodes and not strings so it can be used in translator.go. I kept the GetReadyNodeNames function to avoid refactoring too many things but it now calls the GetReadyNodes function.

Thanks, that makes sense to me, left some minor comments.

@MrHohn
Copy link
Member

MrHohn commented Aug 4, 2018

@lbernail Thanks for the works, this LGTM. Could you squash the fix-up commits?

@lbernail
Copy link
Contributor Author

lbernail commented Aug 6, 2018

Sure, I will take care of it in the next few days

@lbernail
Copy link
Contributor Author

lbernail commented Aug 7, 2018

@MrHohn I squashed the PR into 2 commits, let me know if that works for you
In addition I did some testing and the new changes looks ok too. I tested:

  • master filtering
  • exclude-balancer filtering
  • nodes included in load-balancing in some zones only (instance groups were not created in the other ones)
  • nodes included in load-balancing in all zones

@MrHohn
Copy link
Member

MrHohn commented Aug 7, 2018

@lbernail LGTM. Thanks for verifying the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants