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
Cloud-provider: add event filter method for cloud provider implementations in service controller #108914
Conversation
/triage accepted |
/assign @andrewsykim |
/assign @thockin |
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.
/cc @XudongLiuHarold
@@ -108,6 +111,7 @@ func New( | |||
nodeInformer coreinformers.NodeInformer, | |||
clusterName string, | |||
featureGate featuregate.FeatureGate, | |||
loadBalancerClasses ...*string, |
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.
IF we wanted to do this, I think we want to add an interface method to the LoadBalancers interface for the allowed class names as opposed to adding an additional parameter to the controller constructor.
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.
For most of the existing cloud providers, they handle all of svc change events. Do you think that we need to enforce them to accept this break change?
Here we add an optional parameter to enable filtering on different LoadBalancer Classes. This parameter is not required for existing implementations.
If we need to do this by introducing a new interface. Do you think following interface would be enough ?
type LoadBalancerClassSupported interface {
GetWatchedLoadBalancerClassList() []*string
}
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.
For most of the existing cloud providers, they handle all of svc change events.
I'm not sure what you mean by this, we currently filter for Type=LoadBalancer and when the class is NOT set:
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.
^ adding the filter for when the class is not set was to preserve existing behavior
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.
Yes. For most of the existing cloud providers, they will watch for changes in services whose type is LoadBalancer
I think we are one the same page
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.
Adding a new method here https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/cloud-provider/cloud.go#L133 might make the most sense, but I need to give it more thought
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.
@XudongLiuHarold , any advice is appreciated! Thanks!
if service.Spec.Type == v1.ServiceTypeLoadBalancer { | ||
if service.Spec.LoadBalancerClass == nil { | ||
// Default provider should accept svc, and other provider should ignore | ||
return len(allowedLoadbalancerClass) == 0 |
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.
Shouldn't this just return true
?
If service.Spec.LoadBalancerClass is nil, which means users want to use the cloud provider's load balancer implementation, no matter there is allowedLoadbalancerClass
or not, right?
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.
Imagine there are a few cloud providers available. the default provider will handle all svc whose type is ServiceTypeLoadBalancer and LoadBalancerClass is nil. allowedLoadbalancerClass is empty if this informer is created by default provider
other providers only handle svc whose LoadBalancerClass is not nil. allowedLoadbalancerClass is not empty, the provider here will only handle request whose LoadBalancerClass falls in allowedLoadbalancerClass
IF LoadBalancerClass is nil, This svc should be ignored by other provider and handled by the default provider
|
||
// if LoadBalancerClass is set, the user does not want the default cloud-provider Load Balancer | ||
for _, className := range allowedLoadbalancerClass { | ||
if strings.EqualFold(*className, *service.Spec.LoadBalancerClass) { |
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.
If we found the supported LoadBalancerClass, shouldn't we return false
for cloud providers? Since users indicate that they don't want the cloud providers' load balancer implementation and we also found that the implementation they want to use is also supported.
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.
wantloadbalancer return true only when svc is accpeted by current load balancer implementation. The svc is accepted only when svc meets LoadBalancerClass requirement set by loadbalancer implementation.
If this controller is launched by non-default cloud provider, here it should return true.
@@ -97,6 +98,8 @@ type Controller struct { | |||
nodeSyncCh chan interface{} | |||
// needFullSync indicates if the nodeSyncInternal will do a full node sync on all LB services. | |||
needFullSync bool | |||
// loadBalancerClasses indicates list of accepted LoadbalancerClasses. if empty, the provider accepts all. | |||
loadBalancerClasses []*string |
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.
If we're going to allow the provider implementations to allow-list the class names they should watch, it should be done through the LoadBalancer interface instead of a parameter into the controllers constructor.
Btw, I also added this topic in the next SIG meeting in case other folks have thoughts/opinons on this.
I attended the SIG Meeting(but didn't say anything) and we would like to add an extra function in cloudprovider interface. wouldn't we? @andrewsykim |
Signed-off-by: MartinForReal <fanshangxiang@gmail.com>
7814d88
to
46fa449
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: MartinForReal The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @andrewsykim, @XudongLiuHarold , I added a method in cloud provider and the implementation would decide whether service object should be put into worker queue. Any advice is appreciated. Thanks! |
@MartinForReal: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
1.24 has been released and I received an email about calling for kep. Should I wirte a kep first? |
@MartinForReal: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
Signed-off-by: MartinForReal fanshangxiang@gmail.com
What type of PR is this?
/kind feature
What this PR does / why we need it:
Add LoadBalancerClass filter in service controller of cloud-provifer
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: