Skip to content

Add frontend-nlb-private-ipv4-addresses annotation for internal NLB static IPs - #4867

Open
danny6212000 wants to merge 2 commits into
kubernetes-sigs:mainfrom
danny6212000:frontend-nlb-private-ipv4-addresses
Open

Add frontend-nlb-private-ipv4-addresses annotation for internal NLB static IPs#4867
danny6212000 wants to merge 2 commits into
kubernetes-sigs:mainfrom
danny6212000:frontend-nlb-private-ipv4-addresses

Conversation

@danny6212000

Copy link
Copy Markdown

Description

When frontend NLB is configured as internal via alb.ingress.kubernetes.io/frontend-nlb-scheme: "internal", there is currently no way to assign static private IPv4 addresses to the NLB. This is needed
for scenarios where downstream consumers require stable IP addresses for allowlisting or DNS configuration.

This PR adds a new annotation:
alb.ingress.kubernetes.io/frontend-nlb-private-ipv4-addresses: "10.0.1.10, 10.0.2.10"

The implementation mirrors the existing frontend-nlb-eip-allocations annotation:

  • Validates that the NLB scheme is internal
  • Validates each value is a valid IPv4 address
  • Ensures mutual exclusivity with frontend-nlb-eip-allocations
  • Requires address count to match subnet count
  • Ensures all ingresses in a group specify the same addresses

The annotation is opt-in and has no effect on existing configurations.

Fixes #4857

Validation

  • Unit tests covering happy path, scheme validation, count mismatch, mutual exclusivity, and invalid IP
    format
  • Full pkg/ingress/ test suite passes
  • Manually validated on EKS (ap-northeast-2): internal frontend NLB created with static private IPv4
    addresses (10.99.1.100, 10.99.2.100) confirmed via aws elbv2 describe-load-balancers

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

…tatic IPs

This adds support for assigning static private IPv4 addresses to an
internal frontend NLB via a new annotation:
alb.ingress.kubernetes.io/frontend-nlb-private-ipv4-addresses

The implementation mirrors the existing EIP allocation annotation:
- Validates that the scheme is internal
- Validates IPv4 address format
- Checks mutual exclusivity with EIP allocations
- Matches address count to subnet count

Includes unit tests and documentation updates.
@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 3, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: danny6212000 / name: danny6212000 (d54f706)

@kubernetes-prow

Copy link
Copy Markdown
Contributor

Welcome @danny6212000!

It looks like this is your first PR to kubernetes-sigs/aws-load-balancer-controller 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/aws-load-balancer-controller has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@kubernetes-prow kubernetes-prow Bot 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 Aug 3, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Hi @danny6212000. 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.

Details

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.

@kubernetes-prow kubernetes-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 3, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: danny6212000
Once this PR has been reviewed and has the lgtm label, please assign shraddhabang for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details 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

@kubernetes-prow
kubernetes-prow Bot requested review from oliviassss and shuqz August 3, 2026 10:59
@kubernetes-prow kubernetes-prow Bot 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 Aug 3, 2026
@wweiwei-li wweiwei-li 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 Aug 13, 2026
@oliviassss
oliviassss requested a lite review from Copilot August 18, 2026 17:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for configuring static private IPv4 addresses for internal frontend NLBs created by the ingress model builder, via a new Ingress annotation. This extends the existing “frontend NLB” feature to cover internal static addressing needs (similar to the existing EIP support for internet-facing frontend NLBs).

Changes:

  • Add parsing/validation for alb.ingress.kubernetes.io/frontend-nlb-private-ipv4-addresses and plumb values into NLB subnet mappings.
  • Enforce mutual exclusivity between frontend-nlb-eip-allocations and the new private IPv4 annotation, and validate scheme/count/IP format.
  • Add unit tests and documentation entries for the new annotation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
pkg/ingress/model_build_frontend_nlb.go Implements new annotation parsing/validation and sets SubnetMapping.PrivateIPv4Address for internal frontend NLBs.
pkg/ingress/model_build_frontend_nlb_test.go Adds unit tests covering core private IPv4 behaviors (happy path + validation failures).
pkg/annotations/constants.go Introduces the new annotation suffix constant.
docs/guide/ingress/annotations.md Documents the new annotation and adds it to the annotations index table.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/guide/ingress/annotations.md Outdated
- If you include the subnets [annotation](#frontend-nlb-subnets) it must have the same number of subnets as this annotation has addresses
- NLB must be internal (scheme must be `internal`)
- Mutually exclusive with [frontend-nlb-eip-allocations](#frontend-nlb-eip-allocations)
- Each address must be a valid IPv4 address within the respective subnet's CIDR range

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can we add the cidr range check instead?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@oliviassss HI,Thanks for the review! Done in fc5c620. Added CIDR range validation using the same pattern as the service NLB implementation (networking.GetSubnetAssociatedIPv4CIDRs + FilterIPsWithinCIDRs). The controller auto-matches each IP to its corresponding subnet via CIDR.

Also added unit tests for:

  • Ingress group consistency conflict (different addresses across group members → error)
  • CIDR mismatch (IP not within any subnet's CIDR → error)

Manually re-validated on EKS (ap-northeast-2) with the updated image — tested correct CIDR matching (reversed IP order), out-of-CIDR rejection, and duplicate-subnet detection. All working as expected.

Comment on lines +165 to +168
for _, privateIPv4Addresses := range privateIPv4AddressesList[1:] {
if !cmp.Equal(chosenPrivateIPv4Addresses, privateIPv4Addresses, equality.IgnoreStringSliceOrder()) {
return nil, errors.Errorf("all private IPv4 addresses for the ingress group must be the same: %v | %v", chosenPrivateIPv4Addresses, privateIPv4Addresses)
}
…tency test

- Use CIDR-based matching (same pattern as service NLB) instead of index-based
  mapping. Address ordering no longer matters.
- Validate each private IPv4 address falls within a subnet CIDR using
  networking.GetSubnetAssociatedIPv4CIDRs + FilterIPsWithinCIDRs.
- Add unit test: ingress group members with different addresses → error.
- Add unit test: IP not within subnet CIDR → error.
- Update mock subnets with CidrBlock for CIDR validation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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.

[Feature request] Support frontend-nlb-private-ipv4-addresses annotation for internal frontend NLB

4 participants