Skip to content

add support for loadBalancerClass #2489

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

Merged
merged 5 commits into from
Feb 8, 2022

Conversation

kishorj
Copy link
Collaborator

@kishorj kishorj commented Feb 2, 2022

Issue

Fixes: #2466
Fixes: #2492

Description

Add support for service spec.loadBalancerClass. The load balancer class provides a similar mechanism to the current service annotation service.beta.kubernetes.io/aws-load-balancer-type: "external" to offload reconciling of load balancer from the kubernetes in-tree controller, but it is agnostic to the cloudprovider - KEP-1959 for details. The load balancer class is beta starting k8s 1.22.

The AWS Load Balancer controller will support the spec.loadBalancerClass starting v2.4.0 on k8s 1.22 and later. Here is the summary of the changes

  • default LoadBalancerClass is service.k8s.aws/nlb, users can modify via controller command line flag --load-balancer-class
  • with spec.loadBalancerClass, users no longer need to specify the annotation service.beta.kubernetes.io/aws-load-balancer-type on k8s 1.22 and later
  • Target type defaults to instance for service with loadBalancerClass specified on supported k8s
  • If loadBalancerClass is configured, when the user modifies the service type from LoadBalancer to something else, controller will deallocate the provisioned load balancer
  • Provide a feature gate ServiceTypeLoadBalancerOnly which limits the controller to service of type LoadBalancer for NLB
  • error out during reconcile for instance target if NodePort is not allocated

Tests:

  • controller honors the spec.loadBalancerClass configuration on k8s 1.22
  • controller works as expected on earlier k8s versions

Checklist

  • Added tests that cover your change (if possible)
  • Added/modified documentation as required (such as the README.md, or the docs directory)
  • Manually tested
  • Made sure the title of the PR is a good description that can go into the release notes

BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯

  • Backfilled missing tests for code in same general area 🎉
  • Refactored something and made the world a better place 🌟

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 2, 2022
@k8s-ci-robot k8s-ci-robot requested a review from M00nF1sh February 2, 2022 01:53
@kishorj kishorj added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Feb 2, 2022
@kishorj kishorj force-pushed the load-balancer-class branch from 042e39c to f4ba71d Compare February 2, 2022 20:03
@kishorj kishorj marked this pull request as ready for review February 2, 2022 22:43
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 2, 2022
@M00nF1sh
Copy link
Collaborator

M00nF1sh commented Feb 2, 2022

i think we can use service.k8s.aws/nlb to align with our IngressClass's ingress.k8s.aws/alb name. also it denotes it's a NLB :D

@kishorj kishorj force-pushed the load-balancer-class branch from 632addb to 982eb05 Compare February 3, 2022 18:26
@codecov-commenter
Copy link

codecov-commenter commented Feb 3, 2022

Codecov Report

Attention: Patch coverage is 81.13208% with 10 lines in your changes missing coverage. Please review.

Project coverage is 53.51%. Comparing base (fe212ae) to head (bc9ec0f).
Report is 459 commits behind head on main.

Files with missing lines Patch % Lines
pkg/config/feature_gates.go 0.00% 3 Missing ⚠️
pkg/config/service_config.go 0.00% 2 Missing ⚠️
pkg/service/model_builder.go 81.81% 1 Missing and 1 partial ⚠️
pkg/service/service_utils.go 92.85% 1 Missing and 1 partial ⚠️
pkg/config/controller_config.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2489      +/-   ##
==========================================
+ Coverage   53.38%   53.51%   +0.13%     
==========================================
  Files         140      142       +2     
  Lines        7988     8026      +38     
==========================================
+ Hits         4264     4295      +31     
- Misses       3406     3412       +6     
- Partials      318      319       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 4, 2022
Copy link
Collaborator

@M00nF1sh M00nF1sh left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 7, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kishorj, M00nF1sh

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit dce29ad into kubernetes-sigs:main Feb 8, 2022
@kishorj kishorj deleted the load-balancer-class branch February 18, 2022 18:34
Timothy-Dougherty pushed a commit to adammw/aws-load-balancer-controller that referenced this pull request Nov 9, 2023
* add support for loadBalancerClass

* throw error in case of unallocated NodePort

* centralize IsServiceSupported logic

* handle lb type annotation change for type LoadBalancer

* refactor IsServiceSupported
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle incompatible Service.spec.allocateLoadBalancerNodePorts value loadBalancerClass support?
5 participants