Skip to content
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

udproute: add support for round-robin load balancing #117

Merged
merged 3 commits into from
Oct 19, 2023

Conversation

aryan9600
Copy link
Member

@aryan9600 aryan9600 commented Oct 15, 2023

Add support for distributing traffic amongst several backends for a UDPRoute in a round-robin fashion. High level changes:

  • The target field in the Targets protobuf message has been updated to be a list named targets.
  • The bpf map BACKENDS has been updated to be of type <BackendKey, BackendList>, where BackendList contains a list of Backends.
  • A new bpf map GATEWAY_INDEXES of type <BackendKey, u16> has been introduced to keep track of the last backend that received a packet.

Deletion handling for TCPRoute and UDPRoute has also been improved by avoiding fetching related Endpoints, which could lead to objects being stuck with finalizers.

Fixes #10

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 15, 2023
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 15, 2023
@shaneutt shaneutt added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Oct 17, 2023
@shaneutt shaneutt requested review from astoycos and mlavacca October 17, 2023 20:29
Copy link
Member

@shaneutt shaneutt left a comment

Choose a reason for hiding this comment

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

This is looking really good, thank you for taking the time to knock this one out @aryan9600!

This review was my first pass that you, @astoycos and myself jumped on a Zoom for, and most of these comments are related to follow ups e.t.c.

We'll want to make sure we get review from Andrew as well:

/cc @astoycos


ip := net.ParseIP(addr.IP)

podip := binary.BigEndian.Uint32(ip.To4())
Copy link
Member

Choose a reason for hiding this comment

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

There's a couple places where we implicitly assume V4, this is totally fine for now, but if we don't have an issue tracking adding V6 support we should create that.

Copy link
Member

Choose a reason for hiding this comment

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

@aryan9600 aryan9600 force-pushed the round-robin branch 2 times, most recently from ea15f25 to 062cb70 Compare October 18, 2023 19:15
Add support for round-robin load balancing for UDPRoute. This enables
mutliple backend references in a UDPRoute object, with traffic being
distributed to each backend in a round-robin fashion.

A new BPF map `GATEWAY_INDEXES` was introduced to help keep track of the
"last active" backend, to help determine the backend for the next
UDP packet.

Signed-off-by: Sanskar Jaiswal <[email protected]>
Avoid fetching Endpoints while deleting the Targets in the dataplane,
since we only need the Gateway's IP addr and port for such an action.
This avoids potential errors that can arise due to an Endpoint being
deleted before the reconciler reacts to a UDPRoute/TCPRoute's deletion,
which can block the object from being garbage collected forever due to
the presence of finalizers.

Signed-off-by: Sanskar Jaiswal <[email protected]>
@astoycos
Copy link
Member

/lgtm
/approve

Had a good zoom review I think this a really good start on complete round-robin support for UDP and TC thanks @aryan9600 !!!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 19, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aryan9600, astoycos

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 19, 2023
@k8s-ci-robot k8s-ci-robot merged commit b6e17b3 into kubernetes-sigs:main Oct 19, 2023
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
Development

Successfully merging this pull request may close these issues.

UDP round-robin load-balancing
4 participants