-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[feat aga] Add AGA listener support without auto-discovery #4436
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
shraddhabang
merged 2 commits into
kubernetes-sigs:AGAController
from
shraddhabang:agalistbuilder
Nov 19, 2025
+5,738
−96
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # This patch adds the GlobalAccelerator validator webhook configuration to the webhook configurations | ||
| apiVersion: admissionregistration.k8s.io/v1 | ||
| kind: ValidatingWebhookConfiguration | ||
| metadata: | ||
| name: webhook-configuration | ||
| webhooks: | ||
| - name: vglobalaccelerator.aga.k8s.aws | ||
| rules: | ||
| - apiGroups: | ||
| - "aga.k8s.aws" | ||
| apiVersions: | ||
| - v1beta1 | ||
| operations: | ||
| - CREATE | ||
| - UPDATE | ||
| resources: | ||
| - globalaccelerators | ||
| scope: "Namespaced" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| package aga | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "github.com/pkg/errors" | ||
| agaapi "sigs.k8s.io/aws-load-balancer-controller/apis/aga/v1beta1" | ||
| agamodel "sigs.k8s.io/aws-load-balancer-controller/pkg/model/aga" | ||
| "sigs.k8s.io/aws-load-balancer-controller/pkg/model/core" | ||
| ) | ||
|
|
||
| // listenerBuilder builds Listener model resources | ||
| type listenerBuilder interface { | ||
| Build(ctx context.Context, stack core.Stack, accelerator *agamodel.Accelerator, listeners []agaapi.GlobalAcceleratorListener) ([]*agamodel.Listener, error) | ||
| } | ||
|
|
||
| // NewListenerBuilder constructs new listenerBuilder | ||
| func NewListenerBuilder() listenerBuilder { | ||
| return &defaultListenerBuilder{} | ||
| } | ||
|
|
||
| var _ listenerBuilder = &defaultListenerBuilder{} | ||
|
|
||
| type defaultListenerBuilder struct{} | ||
|
|
||
| // Build builds Listener model resources | ||
| func (b *defaultListenerBuilder) Build(ctx context.Context, stack core.Stack, accelerator *agamodel.Accelerator, listeners []agaapi.GlobalAcceleratorListener) ([]*agamodel.Listener, error) { | ||
| if listeners == nil || len(listeners) == 0 { | ||
| return nil, nil | ||
| } | ||
|
|
||
| var result []*agamodel.Listener | ||
| for i, listener := range listeners { | ||
| listenerModel, err := buildListener(ctx, stack, accelerator, listener, i) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| result = append(result, listenerModel) | ||
| } | ||
| return result, nil | ||
| } | ||
|
|
||
| // buildListener builds a single Listener model resource | ||
| func buildListener(ctx context.Context, stack core.Stack, accelerator *agamodel.Accelerator, listener agaapi.GlobalAcceleratorListener, index int) (*agamodel.Listener, error) { | ||
| spec, err := buildListenerSpec(ctx, accelerator, listener) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| resourceID := fmt.Sprintf("Listener-%d", index) | ||
| listenerModel := agamodel.NewListener(stack, resourceID, spec, accelerator) | ||
| return listenerModel, nil | ||
| } | ||
|
|
||
| // buildListenerSpec builds the ListenerSpec for a single Listener model resource | ||
| func buildListenerSpec(ctx context.Context, accelerator *agamodel.Accelerator, listener agaapi.GlobalAcceleratorListener) (agamodel.ListenerSpec, error) { | ||
| protocol, err := buildListenerProtocol(ctx, listener) | ||
| if err != nil { | ||
| return agamodel.ListenerSpec{}, err | ||
| } | ||
|
|
||
| portRanges, err := buildListenerPortRanges(ctx, listener) | ||
| if err != nil { | ||
| return agamodel.ListenerSpec{}, err | ||
| } | ||
|
|
||
| clientAffinity := buildListenerClientAffinity(ctx, listener) | ||
|
|
||
| return agamodel.ListenerSpec{ | ||
| AcceleratorARN: accelerator.AcceleratorARN(), | ||
| Protocol: protocol, | ||
| PortRanges: portRanges, | ||
| ClientAffinity: clientAffinity, | ||
| }, nil | ||
| } | ||
|
|
||
| // buildListenerProtocol determines the protocol for the listener | ||
| func buildListenerProtocol(_ context.Context, listener agaapi.GlobalAcceleratorListener) (agamodel.Protocol, error) { | ||
| if listener.Protocol == nil { | ||
| // TODO: Auto-discovery feature - Auto-determine protocol from endpoints if nil | ||
| // Return error until auto-discovery feature is implemented | ||
| return "", errors.New("listener protocol must be specified (auto-discovery not yet implemented)") | ||
| } | ||
|
|
||
| switch *listener.Protocol { | ||
| case agaapi.GlobalAcceleratorProtocolTCP: | ||
| return agamodel.ProtocolTCP, nil | ||
| case agaapi.GlobalAcceleratorProtocolUDP: | ||
| return agamodel.ProtocolUDP, nil | ||
| default: | ||
| return "", errors.Errorf("unsupported protocol: %s", *listener.Protocol) | ||
| } | ||
| } | ||
|
|
||
| // buildListenerPortRanges determines the port ranges for the listener | ||
| func buildListenerPortRanges(_ context.Context, listener agaapi.GlobalAcceleratorListener) ([]agamodel.PortRange, error) { | ||
| if listener.PortRanges == nil { | ||
| // TODO: Auto-discovery feature - Auto-determine port ranges from endpoints if nil | ||
| // Return error until auto-discovery feature is implemented | ||
| return []agamodel.PortRange{}, errors.New("listener port ranges must be specified (auto-discovery not yet implemented)") | ||
| } | ||
|
|
||
| var portRanges []agamodel.PortRange | ||
| for _, pr := range *listener.PortRanges { | ||
| // Required validations are already done webhooks and CEL | ||
| portRanges = append(portRanges, agamodel.PortRange{ | ||
| FromPort: pr.FromPort, | ||
| ToPort: pr.ToPort, | ||
| }) | ||
| } | ||
| return portRanges, nil | ||
| } | ||
|
|
||
| // buildListenerClientAffinity determines the client affinity for the listener | ||
| func buildListenerClientAffinity(_ context.Context, listener agaapi.GlobalAcceleratorListener) agamodel.ClientAffinity { | ||
| switch listener.ClientAffinity { | ||
| case agaapi.ClientAffinitySourceIP: | ||
| return agamodel.ClientAffinitySourceIP | ||
| default: | ||
| // Default to NONE as per AWS Global Accelerator behavior | ||
| return agamodel.ClientAffinityNone | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.