-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add webhook for claiming load balancers without LoadBalancerClass #2925
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
Conversation
@olemarkus, thanks for the PR, we are also tracking this feature internally for the upcoming v2.5.0 release and working on the webhook changes :). We intend to make the lb controller default for all new services of type LoadBalancer either by adding the annotation or specifying the load balancer class. We will include some changes from your PR. |
webhooks/core/service_mutator.go
Outdated
if svc.Annotations == nil { | ||
svc.Annotations = make(map[string]string) | ||
} | ||
svc.Annotations["service.beta.kubernetes.io/aws-load-balancer-scheme"] = "internet-facing" |
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.
due to security reasons, we do not want to create an internet-facing load balancer by default. The end user needs to be explicit they want to create an internet-facing load balancer.
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'm aware. But kubetest2 needs to confirm connectivity with the LB, so it would be a breaking change if we do not do this when the LB class is empty. One could very well say that kubernetes requires the CCM controller (and those that emulate it) to create a public cloud LB by default.
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.
What we probably have to do here is to introduce a compatibility mode flag. I can imagine people want both behaviors.
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'm looking forward to merging the changes for v2.5.0. Lets limit the webhook to setting the spec.loadBalancerClass. We will leave the default service as internal for now. I'm open to providing a flag to change the default behavior in future releases.
webhooks/core/service_mutator.go
Outdated
svc.Annotations = make(map[string]string) | ||
} | ||
svc.Annotations["service.beta.kubernetes.io/aws-load-balancer-scheme"] = "internet-facing" | ||
svc.Annotations["service.beta.kubernetes.io/aws-load-balancer-target-type"] = "instance" |
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.
We can make it default to the controller's configuration.
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.
We definitely want this one to be configurable. Especially since ipv6 NLBs doesn't support instance targeting.
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.
default target type is already configurable at the controller level, lets remove it as well.
My approach to this problem is to add a flag that makes LBC the default service controller. johngmyers@5f2da30 was my first attempt, but that commit incorrectly conflates being the default service controller with specifying the default target-type. #2840 addresses setting the default target-type; once that is resolved I was planning on sending a follow-up adding a flag to make LBC the default service controller. |
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## main #2925 +/- ##
=======================================
Coverage 54.40% 54.40%
=======================================
Files 145 145
Lines 8429 8429
=======================================
Hits 4586 4586
Misses 3512 3512
Partials 331 331 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
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 plan to include the webhook configuration in the helm chart, enabled by default the helm chart, with an option to disable if needed.
webhooks/core/service_mutator.go
Outdated
if svc.Annotations == nil { | ||
svc.Annotations = make(map[string]string) | ||
} | ||
svc.Annotations["service.beta.kubernetes.io/aws-load-balancer-scheme"] = "internet-facing" |
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'm looking forward to merging the changes for v2.5.0. Lets limit the webhook to setting the spec.loadBalancerClass. We will leave the default service as internal for now. I'm open to providing a flag to change the default behavior in future releases.
webhooks/core/service_mutator.go
Outdated
svc.Annotations = make(map[string]string) | ||
} | ||
svc.Annotations["service.beta.kubernetes.io/aws-load-balancer-scheme"] = "internet-facing" | ||
svc.Annotations["service.beta.kubernetes.io/aws-load-balancer-target-type"] = "instance" |
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.
default target type is already configurable at the controller level, lets remove it as well.
For v2.5.0, we intend to change the perquisite to k8s 1.22 or later. Setting the spec.loadBalancerClass would be sufficient to make the LBC the default controller for service of type load balancer. |
webhooks/core/service_mutator.go
Outdated
if svc.Annotations == nil { | ||
svc.Annotations = make(map[string]string) | ||
} | ||
svc.Annotations["service.beta.kubernetes.io/aws-load-balancer-scheme"] = "internet-facing" | ||
svc.Annotations["service.beta.kubernetes.io/aws-load-balancer-target-type"] = "instance" |
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 svc.Annotations == nil { | |
svc.Annotations = make(map[string]string) | |
} | |
svc.Annotations["service.beta.kubernetes.io/aws-load-balancer-scheme"] = "internet-facing" | |
svc.Annotations["service.beta.kubernetes.io/aws-load-balancer-target-type"] = "instance" |
Thanks for the comments. How do you want to proceed with this this? Should I amend this PR and then you pull this into your internal changes? |
Lets amend the PR, I can merge in the suggested changes as well. Once we merge this change, we can add the webhook manifest. |
0449794
to
e80b41a
Compare
e80b41a
to
9aa07b8
Compare
Cool. Amended. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kishorj, olemarkus The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
Description
Kubernetes on AWS have two service controllers, this one (LBC) and the one that sits with Cloud Controller Manager (CCM). The CCM repo has a significant amount of bugs/issues related to it, and the most common resolution is to refer the users to LBC.
As a secondary issue, CCM will default, and only fully support classic ELBs.
A third issue is that in IPv6-only clusters, you have to use NLBs, so the CCM controller doesn't work at all.
The requirements for a solution is something like this:
I don't think implementing CCM's controller in LBC is all that feasible. And it may be a moving target, as behaviour in CCM may change as well.
The easiest solution I could think of is to add a webhook that mutates services, adding some annotations and LoadBalancerClass if none are set. This effectively makes LBC the default while CCM will continue to operate on existing services. Migrating an existing service would have to be done through deletion and recreation of the Service resource, but that would be the case today as well since LoadBalancerClass is immutable, and LBC has no way of just adopting an ELB from CCM.
This PR creates a proof of concept that makes the few cloud LB related e2e tests pass and does some minimal configuration of the appropriate annotations (e.g without service class set, the service should be internet-facing by default). More of the CCM annotations needs to be implemented here. There should also be an option to skip the mutation if a specific annotation is set if one really wants CCM to manage a specific service. A feature gate that just noops the webhook should also be added to allow the webhook configuration to exist in the cluster, but disable its functionality.
If this has merit, I can add this functionality, but right now I am just looking for input.
Checklist
README.md
, or thedocs
directory)BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯