Skip to content

Conversation

@shraddhabang
Copy link
Collaborator

This PR adds support for cross-namespace references to the AWS Global Accelerator controller, allowing a GlobalAccelerator resource to reference endpoints (Ingress, Service, Gateway) located in different namespaces using ReferenceGrant resources from the Gateway API.

Changes

  • Implemented cross-namespace validation for GlobalAccelerator endpoints
  • Added support for resolving references to resources in different namespaces
  • Updated endpoint loader to respect ReferenceGrant permissions
  • Added ReferenceGrant event handlers to trigger reconciliation when grants are created/updated/deleted
  • Added e2e tests for cross-namespace references with various endpoint types

How It Works

The controller now checks for the existence of ReferenceGrant resources that explicitly allow cross-namespace references. When a GlobalAccelerator attempts to reference an endpoint in another namespace:

  1. If no ReferenceGrant exists, the reference is rejected with a warning
  2. When a valid ReferenceGrant is created, the controller reconciles the GlobalAccelerator and establishes the endpoint connection

Testing

  • Added comprehensive e2e tests for:

    • Ingress endpoints in different namespaces
    • Service endpoints in different namespaces
    • Gateway API endpoints in different namespaces
    • Auto-discovery with cross-namespace references
    • Mixed endpoint types across multiple namespaces

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 🌟

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: shraddhabang

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

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 16, 2026
for _, from := range impactedFroms {

var gaList agaapi.GlobalAcceleratorList
if err := h.k8sClient.List(ctx, &gaList, &client.ListOptions{Namespace: string(from.Namespace)}); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there any caching you can do here to prevent calling List() on the same namespace multiple times? I think the client should handle this case, but adding an explicit cache might make things cleaner 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.

Ohh are you concerned they might have multiple same namespace references in single grant or you thinking across grants?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I took a look at the Reference Grant structure, and the comment I made doesn't make sense (sorry). I see the existing reference grant logic also does this same listing.


!!!note "To use cross-namespace references"

1. The Gateway API CRDs must be installed in your cluster (specifically the ReferenceGrant CRD)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can be explicit here and say that Reference grant is installed via "standard crds" https://kubernetes-sigs.github.io/aws-load-balancer-controller/latest/guide/gateway/gateway/#prerequisites

}

// grantAllowsReference checks if a specific ReferenceGrant allows the reference
func (v *ReferenceGrantValidator) grantAllowsReference(grant gwv1beta1.ReferenceGrant,
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 refactor this reference grant logic and the gateway reference grant logic into a shared resource?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you choose to not refactor this, I think it should have private visibility.

}

// Validate cross-namespace reference using ReferenceGrant
if err := l.crossNamespaceValidator.ValidateCrossNamespaceReference(ctx,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose you want a more graceful failure mode here when the user is attempting to use cross namespace referencing but they have forgotten to install the proper CRD.

)

BeforeEach(func() {
if tf.Options.IPFamily == framework.IPv6 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is ipv6 not supported?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The dualstack NLBs with Client IP preservations enabled are not supported hence we have disabled those in our tests.

Expect(err).NotTo(HaveOccurred())

currentTestName := CurrentSpecReport().LeafNodeText
if !strings.Contains(currentTestName, "cross-namespace") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: magic string

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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants