-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[feat aga] Implement endpoint group management with port override conflict resolution #4463
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
k8s-ci-robot
merged 6 commits into
kubernetes-sigs:AGAController
from
shraddhabang:agaegmanagement
Nov 25, 2025
+8,547
−100
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6f2c2b7
setup AGA SDK client
shraddhabang 96676f7
[feat aga] Implement endpoint loader with DNS resolution
shraddhabang 40dce40
[feat aga] Implement resource monitoring for referenced resources
shraddhabang 294450b
[feat aga] few bugfixes and code refactoring
shraddhabang cb2305d
[feat aga] Implement model builder for endpoint groups
shraddhabang a5bfc10
[feat aga] Implement endpoint group deployer with port override confl…
shraddhabang 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| package eventhandlers | ||
|
|
||
| import ( | ||
| "context" | ||
| "github.com/go-logr/logr" | ||
| corev1 "k8s.io/api/core/v1" | ||
| networking "k8s.io/api/networking/v1" | ||
| "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
| "k8s.io/apimachinery/pkg/types" | ||
| "k8s.io/client-go/util/workqueue" | ||
| "sigs.k8s.io/aws-load-balancer-controller/pkg/aga" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
| "sigs.k8s.io/controller-runtime/pkg/event" | ||
| "sigs.k8s.io/controller-runtime/pkg/handler" | ||
| "sigs.k8s.io/controller-runtime/pkg/reconcile" | ||
| gwv1 "sigs.k8s.io/gateway-api/apis/v1" | ||
| ) | ||
|
|
||
| // NewEnqueueRequestsForResourceEvent creates a new handler for generic resource events | ||
| func NewEnqueueRequestsForResourceEvent( | ||
| resourceType aga.ResourceType, | ||
| referenceTracker *aga.ReferenceTracker, | ||
| logger logr.Logger, | ||
| ) handler.EventHandler { | ||
| return &enqueueRequestsForResourceEvent{ | ||
| resourceType: resourceType, | ||
| referenceTracker: referenceTracker, | ||
| logger: logger, | ||
| } | ||
| } | ||
|
|
||
| // enqueueRequestsForResourceEvent handles resource events and enqueues reconcile requests for GlobalAccelerators | ||
| // that reference the resource | ||
| type enqueueRequestsForResourceEvent struct { | ||
| resourceType aga.ResourceType | ||
| referenceTracker *aga.ReferenceTracker | ||
| logger logr.Logger | ||
| } | ||
|
|
||
| // The following methods implement handler.TypedEventHandler interface | ||
|
|
||
| // Create handles Create events with the typed API | ||
| func (h *enqueueRequestsForResourceEvent) Create(ctx context.Context, evt event.TypedCreateEvent[client.Object], queue workqueue.TypedRateLimitingInterface[reconcile.Request]) { | ||
| h.handleResource(ctx, evt.Object, "created", queue) | ||
| } | ||
|
|
||
| // Update handles Update events with the typed API | ||
| func (h *enqueueRequestsForResourceEvent) Update(ctx context.Context, evt event.TypedUpdateEvent[client.Object], queue workqueue.TypedRateLimitingInterface[reconcile.Request]) { | ||
| h.handleResource(ctx, evt.ObjectNew, "updated", queue) | ||
| } | ||
|
|
||
| // Delete handles Delete events with the typed API | ||
| func (h *enqueueRequestsForResourceEvent) Delete(ctx context.Context, evt event.TypedDeleteEvent[client.Object], queue workqueue.TypedRateLimitingInterface[reconcile.Request]) { | ||
| h.handleResource(ctx, evt.Object, "deleted", queue) | ||
| } | ||
|
|
||
| // Generic handles Generic events with the typed API | ||
| func (h *enqueueRequestsForResourceEvent) Generic(ctx context.Context, evt event.TypedGenericEvent[client.Object], queue workqueue.TypedRateLimitingInterface[reconcile.Request]) { | ||
| h.handleResource(ctx, evt.Object, "generic event", queue) | ||
| } | ||
|
|
||
| // handleTypedResource handles resource events for the typed interface | ||
| func (h *enqueueRequestsForResourceEvent) handleResource(_ context.Context, obj interface{}, eventType string, queue workqueue.TypedRateLimitingInterface[reconcile.Request]) { | ||
| var namespace, name string | ||
|
|
||
| // Extract namespace and name based on the object type | ||
| switch res := obj.(type) { | ||
| case *corev1.Service: | ||
| namespace = res.Namespace | ||
| name = res.Name | ||
| case *networking.Ingress: | ||
| namespace = res.Namespace | ||
| name = res.Name | ||
| case *gwv1.Gateway: | ||
| namespace = res.Namespace | ||
| name = res.Name | ||
| case *unstructured.Unstructured: | ||
| namespace = res.GetNamespace() | ||
| name = res.GetName() | ||
| default: | ||
| h.logger.Error(nil, "Unknown resource type", "type", h.resourceType) | ||
| return | ||
| } | ||
|
|
||
| resourceKey := aga.ResourceKey{ | ||
| Type: h.resourceType, | ||
| Name: types.NamespacedName{ | ||
| Namespace: namespace, | ||
| Name: name, | ||
| }, | ||
| } | ||
|
|
||
| // If this resource is not referenced by any GA, no need to queue reconciles | ||
| if !h.referenceTracker.IsResourceReferenced(resourceKey) { | ||
| return | ||
| } | ||
|
|
||
| // Get all GAs that reference this resource | ||
| gaRefs := h.referenceTracker.GetGAsForResource(resourceKey) | ||
|
|
||
| // Queue reconcile for affected GAs | ||
| for _, gaRef := range gaRefs { | ||
| h.logger.V(1).Info("Enqueueing GA for reconcile due to resource event", | ||
| "resourceType", h.resourceType, | ||
| "resourceName", resourceKey.Name, | ||
| "eventType", eventType, | ||
| "ga", gaRef) | ||
|
|
||
| queue.Add(reconcile.Request{NamespacedName: gaRef}) | ||
| } | ||
| } |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider calling this GetDesiredEndpointsFromGA; so that it's obvious these are coming from the spec and not from the current state of the accelerator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes makes sense