Skip to content

Conversation

@wweiwei-li
Copy link
Collaborator

@wweiwei-li wweiwei-li commented Nov 14, 2025

Description

Support BYOIP (Bring Your Own IP) for Global Accelerator

This change enables users to specify custom IP addresses from their own IP address ranges when creating Global Accelerators, instead of relying solely on AWS-provided IP addresses.

Key changes:

  • Added IpAddresses field to Accelerator spec to accept BYOIP CIDRs
  • Implemented CIDR comparison logic to determine when accelerator replacement is required:
    1. If any BYOIP CIDR is shared between current and desired → Allow update to preserve traffic
    2. If no BYOIP CIDR is shared between current and desired → Trigger replacement and document this behavior
  • Added HasSharedIPv4CIDR function to check if desired IPs share /24 CIDR blocks with current IPs
  • Supports API-allowed transitions: adding new BYOIPs or changing IPs within the same CIDR without replacement

Checklist

  • [x ] Added tests that cover your change (if possible)
  • Added/modified documentation as required (such as the README.md, or the docs directory)
  • [x ] Manually tested
  • [x ] 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 k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 14, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wweiwei-li

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 14, 2025
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 15, 2025
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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.

desiredIPs: []string{"169.254.8.16"},
actualIPSets: makeIPSets([]string{"169.254.9.13", "99.82.158.217"}),
expectedResult: false,
description: "Different BYOIP, count matches but IP doesn't",
Copy link
Collaborator

Choose a reason for hiding this comment

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

NIT: Update the description or test case. Count does not match here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, Let me add one more ip to desiredIPs

}

// isSDKAcceleratorRequiresReplacement checks whether a sdk Accelerator requires replacement to fulfill an Accelerator resource.
func isSDKAcceleratorRequiresReplacement(sdkAccelerator AcceleratorWithTags, resAccelerator *agamodel.Accelerator) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add unit tests for isSDKAcceleratorRequiresReplacement so that we can cover different test cases ?
Also can we comment the behavior here on when we consider the replacement or add a task for us to document for it for later?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, Adding it

func isSDKAcceleratorRequiresReplacement(sdkAccelerator AcceleratorWithTags, resAccelerator *agamodel.Accelerator) bool {
// The accelerator will only need replacement in BYOIP scenarios. I will implement this later as a separate PR
// TODO : BYOIP feature
if len(resAccelerator.Spec.IpAddresses) == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens if we had applied BYOIP initially and now we removed it? Do we need a replacement here since we are going from BYOIP to non-BYOIP?

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For BYOIP to non-BYOIP transitions, updating is not supported. BYOIP to non-BYOIP will always need replacement. However, if we made it return true, then every non-BYOIP to non-BYOIP transition would cause replacement unless we have a mechanism like below to check if current IPs include BYOIP (we discussed this internally we try not adding this).

if len(resAccelerator.Spec.IpAddresses) == 0 && hasBYOIP(sdkAccelerator) {
return true
}

so I was thinking for this case we need to document that users need to remove the accelerator first and recreate a new one. This is my intent. Let me try it out to check if it is easy and put together internal documentation for the behavior for discussion. Also I wonder how likely they want to from For BYOIP to non-BYOIP transitions


// HasSharedIPv4CIDR checks if current and desired IPs share any IPv4 CIDR block.
func HasSharedIPv4CIDR(currentIPSets []agatypes.IpSet, desiredIPs []string) bool {
if len(desiredIPs) == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not possible since we have already compared length of desiredIPs aka resAccelerator.Spec.IpAddresses to zero and return false before we call this function right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, since we have checked it at isSDKAcceleratorRequiresReplacement level. We don't need it

description string
}{
{
name: "No desired IPs - has shared CIDR",
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test case wont be required if we remove zero len check for desired IPs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, removing it

// createInput.IpAddresses = resAccelerator.Spec.IpAddresses
//}
// BYOIP feature: Set IP addresses if provided
if len(resAccelerator.Spec.IpAddresses) > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need to do nil check for resAccelerator.Spec and resAccelerator.Spec.IpAddresses

Copy link
Collaborator Author

@wweiwei-li wweiwei-li Nov 18, 2025

Choose a reason for hiding this comment

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

We don't need to do nil check for resAccelerator.Spec and resAccelerator.Spec.IpAddresses. For resAccelerator.Spec, it is a struct. so It can't be nil. No nil check needed. For resAccelerator.Spec.IpAddresses, it is a slice, the len(nil) will return 0 in go.

currentIPv4s := extractIPv4Addresses(sdkAccelerator.Accelerator.IpSets)
desiredBYOIPs := resAccelerator.Spec.IpAddresses
if len(desiredBYOIPs) == 1 {
s.logger.Info("Accelerator requires replacement: BYOIP CIDR change",
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we want to keep it as v(1) logging

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am thinking we should keep it as it is since accelerator replacement is a significant operation that we want it to be accessible by default. Let me know what do you think

func isSDKAcceleratorRequiresReplacement(sdkAccelerator AcceleratorWithTags, resAccelerator *agamodel.Accelerator) bool {
// The accelerator will only need replacement in BYOIP scenarios. I will implement this later as a separate PR
// TODO : BYOIP feature
if len(resAccelerator.Spec.IpAddresses) == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

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. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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.

4 participants