Skip to content

Conversation

pthak94
Copy link
Contributor

@pthak94 pthak94 commented Mar 6, 2025

Issue

#3877

Description

Introduced a new annotation "service.beta.kubernetes.io/aws-load-balancer-proxy-protocol-per-target-group" with which, proxy protocol setting can be configured for each target group individually. Example usage is "80, 443", which will enable proxy protocols for the target groups associated to port 80 and 443 listeners. And disable for the rest, for example port 22.

To achieve this, when target group is created, it's service port is compared to the value of this annotation, if it's found, it's value is set to true, otherwise set to false.

"service.beta.kubernetes.io/aws-load-balancer-proxy-protocol" annotation still overrides this new annotation.

Added test cases to check if the new annotation works, and that it is still overriden by "service.beta.kubernetes.io/aws-load-balancer-proxy-protocol" annotation.

Finally, added documentation regarding this new annotation.

This version of controller is tested in my EKS testing environment.

-->

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 🌟

Copy link

linux-foundation-easycla bot commented Mar 6, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not 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 6, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @pthak94. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 6, 2025
@pthak94 pthak94 changed the title Proxy protocol per target group Added support for setting Proxy protocol per target group based on ServicePort Mar 6, 2025
@pthak94 pthak94 force-pushed the proxy-protocol-per-target-group branch from 862e07e to 800bb02 Compare March 6, 2025 14:59
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 6, 2025
Copy link
Collaborator

@zac-nixon zac-nixon left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution. Please consider my comment.

| [service.beta.kubernetes.io/aws-load-balancer-internal](#lb-internal) | boolean | false | deprecated, in favor of [aws-load-balancer-scheme](#lb-scheme) |
| [service.beta.kubernetes.io/aws-load-balancer-scheme](#lb-scheme) | string | internal | |
| [service.beta.kubernetes.io/aws-load-balancer-proxy-protocol](#proxy-protocol-v2) | string | | Set to `"*"` to enable |
| [service.beta.kubernetes.io/aws-load-balancer-proxy-protocol-per-target-group](#proxy-protocol-v2) | string | | If specified,configures proxy protocol per targrt group based on ServicePort. For example `"80, true, 443, true, 22, false"` will disable proxy protocol for port 22 only. This annotation is overriden by `"service.beta.kubernetes.io/aws-load-balancer-proxy-protocol"` |
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is the correct way to model this information. How about just using a single list 80,443 to denote that those ports should have proxy protocol enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, that indeed makes it simpler. I'll work on your suggestions shortly. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zac-nixon added a new commit with the updated logic. Tweaked the tests and doc as well. Pls take a look.

@pthak94 pthak94 requested a review from zac-nixon March 10, 2025 09:57
if _, enabled := enabledPorts[currentPortStr]; enabled {
rawAttributes[tgAttrsProxyProtocolV2Enabled] = "true"
} else {
rawAttributes[tgAttrsProxyProtocolV2Enabled] = "false"
Copy link
Collaborator

Choose a reason for hiding this comment

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

to keep existing behavior, can you remove this line? the default for this attribute is false anyways.

Copy link
Contributor Author

@pthak94 pthak94 Mar 12, 2025

Choose a reason for hiding this comment

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

@zac-nixon I'm assuming you meant remove only the else block and not the whole line. I can't think of any scenario where this can break the existing behavior. Can you please help me understand?

The intention of having the else block is for a situation where these attributes are set:

"service.beta.kubernetes.io/aws-load-balancer-target-group-attributes": tgAttrsProxyProtocolV2Enabled + "=true"
"service.beta.kubernetes.io/aws-load-balancer-proxy-protocol-per-target-group": "80, 443"

in this case, our new annotation will not do what we say it does, that is disable proxy_protocol for unspecified port 22. It will just enable it for all.

"service.beta.kubernetes.io/aws-load-balancer-proxy-protocol": "*" still overrides everything as the documentation says.

Do let me know what you think?

Copy link
Collaborator

@zac-nixon zac-nixon Mar 15, 2025

Choose a reason for hiding this comment

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

Thanks for the explanation. I was just thinking that it would be nice to not have the false value set when we didn't need it. But I'm happy with the implementation as-is and I appreciate the work you did here :)

@zac-nixon
Copy link
Collaborator

overall looks pretty good. please consider my comment.

i appreciate the contribution!

@zac-nixon
Copy link
Collaborator

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 11, 2025
@zac-nixon
Copy link
Collaborator

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 15, 2025
@zac-nixon zac-nixon added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 17, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: pthak94

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 bee5f8c into kubernetes-sigs:main Mar 17, 2025
8 of 9 checks passed
@pthak94
Copy link
Contributor Author

pthak94 commented Mar 17, 2025

Thanks @zac-nixon :) Do you know when this will be released? we'd like to deploy it on our production environments.

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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants