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

AWS NLB: Support cross-zone load balancing annotation #61064

Merged
merged 1 commit into from Jan 3, 2019

Conversation

johanneswuerbach
Copy link
Contributor

AWS Network Load Balancer recently got support for cross-zone load balancing.

Use the existing service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled
annotation to configure it.

AWS release announcement:
https://aws.amazon.com/about-aws/whats-new/2018/02/network-load-balancer-now-supports-cross-zone-load-balancing/

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):

Special notes for your reviewer:

Release note:

AWS NLB: Support cross-zone load balancing annotation

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. 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. labels Mar 12, 2018
@johanneswuerbach
Copy link
Contributor Author

@chrislovecnm / @jsafrane I'm not entirely sure how to test this as the entire NLB feature seems to be barely test covered, any hints?

@johanneswuerbach
Copy link
Contributor Author

/sig aws

@k8s-ci-robot
Copy link
Contributor

@johanneswuerbach: GitHub didn't allow me to assign the following users: micahhausler.

Note that only kubernetes members and repo collaborators can be assigned.

In response to this:

/assign micahhausler

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.

@johanneswuerbach
Copy link
Contributor Author

/assign @justinsb

@seh
Copy link
Contributor

seh commented May 30, 2018

@justinb, have you taken a look at this PR? I ran into the lack of cross-AZ support for NLBs today, and only discovered the root of the problem by studying the implementation. We have an implementation available here. What's the next step?

@idealhack
Copy link
Member

/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 Jul 3, 2018
Copy link
Member

@micahhausler micahhausler left a comment

Choose a reason for hiding this comment

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

Great work! Just a few changes requested


// Determine if cross zone load balancing enabled/disabled has been specified
crossZoneLoadBalancingEnabledAnnotation := annotations[ServiceAnnotationLoadBalancerCrossZoneLoadBalancingEnabled]
if crossZoneLoadBalancingEnabledAnnotation != "" {
Copy link
Member

Choose a reason for hiding this comment

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

Why add a parameter to ensureLoadBalancerv2() since annotations are already getting passed?

Could you move this logic into ensureLoadBalancerv2()

}
describeAttributesOutput, err := c.elbv2.DescribeLoadBalancerAttributes(describeAttributesRequest)
if err != nil {
glog.Warning("Unable to retrieve load balancer attributes during attribute sync")
Copy link
Member

Choose a reason for hiding this comment

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

Since you're returning the error, you don't need to log it here. Can you wrap it instead?

fmt.Errorf("My error message: %q", err)

return nil, err
}

foundAttributes := &describeAttributesOutput.Attributes
Copy link
Member

Choose a reason for hiding this comment

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

Why dereference this here and add a *foundAttributes below? Why not just

for _, foundAttribute := range describeAttributesOutput.Attributes {
    ...
}

// Whether the ELB was new or existing, sync attributes regardless. This accounts for things
// that cannot be specified at the time of creation and can only be modified after the fact,
// e.g. idle connection timeout.
if len(loadBalancerAttributes) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

It might help this read better if loadBalancerAttributes was renamed to something like desiredLoadBalancerAttributes. Reading below,

if  targetValue, ok := loadBalancerAttributes[*foundAttribute.Key]

would be easier to understand if it was

if targetValue, ok := desiredLoadBalancerAttributes[*foundAttribute.Key]

// Determine if cross zone load balancing enabled/disabled has been specified
crossZoneLoadBalancingEnabledAnnotation := annotations[ServiceAnnotationLoadBalancerCrossZoneLoadBalancingEnabled]
if crossZoneLoadBalancingEnabledAnnotation != "" {
loadBalancerAttributes["load_balancing.cross_zone.enabled"] = crossZoneLoadBalancingEnabledAnnotation
Copy link
Member

Choose a reason for hiding this comment

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

This value should be "true" not whatever string value the user entered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reasoning behind using the value here, was to make setting it explicitly to false work. I know that you could also delete the annotation to revert it to false, but that seemed not really obvious. wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

Yea, you're right true or false could be valid values. Can you make sure you call strconv.ParseBool() like the check for access logs does to make sure the input is valid? https://github.com/kubernetes/kubernetes/blob/master/pkg/cloudprovider/providers/aws/aws.go#L3415-L3425

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed


// Identify to be changed attributes
for _, foundAttribute := range *foundAttributes {
if targetValue, ok := loadBalancerAttributes[*foundAttribute.Key]; ok {
Copy link
Member

Choose a reason for hiding this comment

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

You should add an else case for if !ok, meaning the annotation for the attribute was deleted.

From the docs:

Any existing attributes that you do not modify retain their current values.

If the annotation gets removed, we would want to set the value to "false" and add it to changedAttributes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@micahhausler Wouldn't that mean that we set any value to false, also the attributes k8s doesn't know about and which might have a different default (e.g. routing.http2.enabled, while only being a valid attribute for ALBs defaults to true).

Instead I set now load_balancing.cross_zone.enabled to false by default, so a set annotation will change it, but an eventually removed annotation changes it back to false.

@johanneswuerbach johanneswuerbach force-pushed the nlb-cross-zone branch 2 times, most recently from f478ff6 to ff13751 Compare July 17, 2018 17:39
@micahhausler
Copy link
Member

👍
/lgtm

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

/retest

@johanneswuerbach
Copy link
Contributor Author

/test pull-kubernetes-e2e-gce

@idealhack
Copy link
Member

@kubernetes/sig-aws-misc
ping for approval

@k8s-github-robot
Copy link

/test all

Tests are more than 96 hours old. Re-running tests.

@nikhita
Copy link
Member

nikhita commented Sep 29, 2018

/retest

@itsmepetrov
Copy link

Any updates?

@nukepuppy
Copy link

would be great to get this going.. kind of wasteful otherwise when using NLB

@micahhausler
Copy link
Member

/test pull-kubernetes-godeps

@micahhausler
Copy link
Member

/milestone v1.14

@k8s-ci-robot
Copy link
Contributor

@micahhausler: You must be a member of the kubernetes/kubernetes-milestone-maintainers github team to set the milestone.

In response to this:

/milestone v1.14

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.

@micahhausler
Copy link
Member

/approve

@idealhack
Copy link
Member

/assign @zmerlynn @jsafrane

@idealhack idealhack added this to the v1.14 milestone Dec 20, 2018
@jsafrane
Copy link
Member

jsafrane commented Jan 2, 2019

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: johanneswuerbach, jsafrane, micahhausler

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 2, 2019
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel comment for consistent failures.

AWS Network Load Balancer recently got support for cross-zone load balancing.

Use the existing `service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled`
annotation to configure it.
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 2, 2019
@johanneswuerbach
Copy link
Contributor Author

@jsafrane rebased and replaced glog usage with klog. CI should pass now 🤞

@k8s-ci-robot k8s-ci-robot added the sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. label Jan 2, 2019
@jsafrane
Copy link
Member

jsafrane commented Jan 3, 2019

/lgtm
/retest

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 3, 2019
@k8s-ci-robot k8s-ci-robot merged commit d7e0d9b into kubernetes:master Jan 3, 2019
@johanneswuerbach johanneswuerbach deleted the nlb-cross-zone branch January 4, 2019 19:56
@majidma-ag
Copy link

majidma-ag commented Oct 14, 2020

@johanneswuerbach, can you please let me know if this feature (NLB-cross zone load balancing) is available in kubernetes v1.15 ?

@defyjoy
Copy link

defyjoy commented Feb 4, 2021

AWS docs are not provided for this one . I understand this is a kubernetes only annotation but is it not supposed to be included by AWS docs ? Is this the official doc for the annotation ? Also if I understand correctly this is for the controller annotation for service not for the ingress resource itself .

https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.1/guide/service/annotations/

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. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. 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